Add SANs section and harden INF SAN parsing

This commit is contained in:
2026-01-30 13:03:30 +13:00
parent 61db7ea651
commit b3d3e9300f

View File

@@ -851,6 +851,11 @@ $infCsrOutputLabel.Enabled = $false
$infCsrOutputBox.Enabled = $false $infCsrOutputBox.Enabled = $false
$y += $rowHeight + $gap $y += $rowHeight + $gap
Add-Label "SANs (from INF)" $xLabel $y $labelWidth $rowHeight
$infSanBox = Add-TextBox $xInput $y $inputWidth 80 $true
$infSanBox.ReadOnly = $true
$y += 82 + $gap
$useFqdnBox = Add-CheckBox "Input contains FQDNs (otherwise default zone is appended)" $xInput $y $inputWidth $rowHeight $useFqdnBox = Add-CheckBox "Input contains FQDNs (otherwise default zone is appended)" $xInput $y $inputWidth $rowHeight
$y += $rowHeight + $gap $y += $rowHeight + $gap
@@ -1049,6 +1054,7 @@ $sectionAnchors = @{
} }
$script:infRequests = @() $script:infRequests = @()
$script:infSans = @()
foreach ($key in $sectionAnchors.Keys) { foreach ($key in $sectionAnchors.Keys) {
$label = $navLabels[$key] $label = $navLabels[$key]
@@ -1357,6 +1363,7 @@ function Apply-Layout {
$infImportBtn.Left = $xInput + $inputWidthCalc - $buttonWidth $infImportBtn.Left = $xInput + $inputWidthCalc - $buttonWidth
$infCsrOutputBox.Width = $inputWidthCalc $infCsrOutputBox.Width = $inputWidthCalc
$infCsrOnlyBox.Width = $inputWidthCalc $infCsrOnlyBox.Width = $inputWidthCalc
$infSanBox.Width = $inputWidthCalc
$zoneBox.Width = $inputWidthCalc $zoneBox.Width = $inputWidthCalc
$ipBox.Width = $inputWidthCalc - ($buttonWidth + $buttonGap) $ipBox.Width = $inputWidthCalc - ($buttonWidth + $buttonGap)
$ipRefreshBtn.Left = $xInput + $inputWidthCalc - $buttonWidth $ipRefreshBtn.Left = $xInput + $inputWidthCalc - $buttonWidth
@@ -1483,6 +1490,7 @@ $infImportBtn.Add_Click({
} }
$script:infRequests = @() $script:infRequests = @()
$script:infSans = @()
$infHosts = @() $infHosts = @()
$subjectRemovedCount = 0 $subjectRemovedCount = 0
@@ -1510,18 +1518,25 @@ $infImportBtn.Add_Click({
CsrInf = $csrInfPath CsrInf = $csrInfPath
} }
$infHosts += $hosts $infHosts += $hosts
$script:infSans += @($reqData.Sans)
if ($reqData.CommonName) { if ($reqData.CommonName) {
$sanList = if ($reqData.Sans.Count -gt 0) { $reqData.Sans -join ", " } else { "none" } $sanList = if (@($reqData.Sans).Count -gt 0) { (@($reqData.Sans) -join ", ") } else { "none" }
& $logAction "INF $($infFile.Name): CN=$($reqData.CommonName); SANs=$sanList" & $logAction "INF $($infFile.Name): CN=$($reqData.CommonName); SANs=$sanList"
} }
} }
$infHosts = @($infHosts | Where-Object { $_ } | Sort-Object -Unique) $infHosts = @($infHosts | Where-Object { $_ } | Sort-Object -Unique)
$script:infSans = @($script:infSans | Where-Object { $_ } | Sort-Object -Unique)
if ($infHosts.Count -gt 0) { if ($infHosts.Count -gt 0) {
$currentHosts = Split-List $hostsBox.Text $currentHosts = Split-List $hostsBox.Text
$merged = Merge-Hostnames -Existing $currentHosts -NewItems $infHosts $merged = Merge-Hostnames -Existing $currentHosts -NewItems $infHosts
$hostsBox.Text = ($merged -join [Environment]::NewLine) $hostsBox.Text = ($merged -join [Environment]::NewLine)
} }
if ($script:infSans.Count -gt 0) {
$infSanBox.Text = ($script:infSans -join [Environment]::NewLine)
} else {
$infSanBox.Text = ""
}
& $logAction "Imported $($infFiles.Count) INF file(s), added $($infHosts.Count) hostname(s)." & $logAction "Imported $($infFiles.Count) INF file(s), added $($infHosts.Count) hostname(s)."
if ($subjectRemovedCount -gt 0) { if ($subjectRemovedCount -gt 0) {