Add PFX password toggle

This commit is contained in:
2026-01-30 11:12:27 +13:00
parent d7d0cba5d1
commit 497e9b0c87

View File

@@ -824,6 +824,10 @@ $pfxPasswordBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false
$pfxPasswordBox.UseSystemPasswordChar = $true $pfxPasswordBox.UseSystemPasswordChar = $true
$y += $rowHeight + $gap $y += $rowHeight + $gap
$pfxPasswordToggle = Add-CheckBox "Use PFX password" $xInput $y 180 $rowHeight
$pfxPasswordToggle.Checked = $true
$y += $rowHeight + $gap
Add-Label "ACME base URI" $xLabel $y $labelWidth $rowHeight Add-Label "ACME base URI" $xLabel $y $labelWidth $rowHeight
$baseUriBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false $baseUriBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false
$baseUriBox.Text = "https://acmeprod.wd.govt.nz:9999/acme/rsa/" $baseUriBox.Text = "https://acmeprod.wd.govt.nz:9999/acme/rsa/"
@@ -883,11 +887,15 @@ function Update-OutputTypeUI {
$outputPathLabel.Text = "PEM output path" $outputPathLabel.Text = "PEM output path"
$pfxPasswordLabel.Visible = $false $pfxPasswordLabel.Visible = $false
$pfxPasswordBox.Visible = $false $pfxPasswordBox.Visible = $false
$pfxPasswordToggle.Visible = $false
$pfxPasswordBox.Text = "" $pfxPasswordBox.Text = ""
$pfxPasswordToggle.Checked = $false
} else { } else {
$outputPathLabel.Text = "PFX output path" $outputPathLabel.Text = "PFX output path"
$pfxPasswordLabel.Visible = $true $pfxPasswordLabel.Visible = $true
$pfxPasswordBox.Visible = $true $pfxPasswordBox.Visible = $true
$pfxPasswordToggle.Visible = $true
$pfxPasswordBox.Enabled = $pfxPasswordToggle.Checked -and -not $disableCertsBox.Checked
} }
} }
@@ -1033,7 +1041,8 @@ function Update-CertGenerationUI {
$wacsPathBox.Enabled = -not $disabled $wacsPathBox.Enabled = -not $disabled
$outputTypeBox.Enabled = -not $disabled $outputTypeBox.Enabled = -not $disabled
$outputPathBox.Enabled = -not $disabled $outputPathBox.Enabled = -not $disabled
$pfxPasswordBox.Enabled = -not $disabled $pfxPasswordToggle.Enabled = -not $disabled
$pfxPasswordBox.Enabled = -not $disabled -and $pfxPasswordToggle.Checked
$baseUriBox.Enabled = -not $disabled $baseUriBox.Enabled = -not $disabled
$validationBox.Enabled = -not $disabled $validationBox.Enabled = -not $disabled
$validationPortBox.Enabled = -not $disabled $validationPortBox.Enabled = -not $disabled
@@ -1084,6 +1093,9 @@ if ($loadedDefaults) {
$value = Get-DefaultValue -Defaults $loadedDefaults -Name "PfxPassword" $value = Get-DefaultValue -Defaults $loadedDefaults -Name "PfxPassword"
if (-not [string]::IsNullOrWhiteSpace($value)) { $pfxPasswordBox.Text = $value } if (-not [string]::IsNullOrWhiteSpace($value)) { $pfxPasswordBox.Text = $value }
$value = Get-DefaultValue -Defaults $loadedDefaults -Name "UsePfxPassword"
if ($null -ne $value) { $pfxPasswordToggle.Checked = [bool]$value }
$value = Get-DefaultValue -Defaults $loadedDefaults -Name "BaseUri" $value = Get-DefaultValue -Defaults $loadedDefaults -Name "BaseUri"
if (-not [string]::IsNullOrWhiteSpace($value)) { $baseUriBox.Text = $value } if (-not [string]::IsNullOrWhiteSpace($value)) { $baseUriBox.Text = $value }
@@ -1152,6 +1164,7 @@ function Apply-Layout {
$outputTypeBox.Width = $inputWidthCalc $outputTypeBox.Width = $inputWidthCalc
$outputPathBox.Width = $inputWidthCalc $outputPathBox.Width = $inputWidthCalc
$pfxPasswordBox.Width = $inputWidthCalc $pfxPasswordBox.Width = $inputWidthCalc
$pfxPasswordToggle.Width = $inputWidthCalc
$baseUriBox.Width = $inputWidthCalc $baseUriBox.Width = $inputWidthCalc
$validationBox.Width = $inputWidthCalc $validationBox.Width = $inputWidthCalc
$validationPortBox.Width = $inputWidthCalc $validationPortBox.Width = $inputWidthCalc
@@ -1180,6 +1193,10 @@ $replicationEnabledBox.Add_CheckedChanged({
if (Test-Path function:Update-ReplicationUI) { Update-ReplicationUI } if (Test-Path function:Update-ReplicationUI) { Update-ReplicationUI }
}) })
$pfxPasswordToggle.Add_CheckedChanged({
$pfxPasswordBox.Enabled = $pfxPasswordToggle.Checked -and -not $disableCertsBox.Checked
})
$filePreviewBtn.Add_Click({ $filePreviewBtn.Add_Click({
$path = $fileBox.Text.Trim() $path = $fileBox.Text.Trim()
if ([string]::IsNullOrWhiteSpace($path)) { if ([string]::IsNullOrWhiteSpace($path)) {
@@ -1321,6 +1338,7 @@ $saveDefaultsBtn.Add_Click({
OutputType = $outputTypeBox.SelectedItem.ToString() OutputType = $outputTypeBox.SelectedItem.ToString()
OutputPath = $outputPathBox.Text OutputPath = $outputPathBox.Text
PfxPassword = $pfxPasswordBox.Text PfxPassword = $pfxPasswordBox.Text
UsePfxPassword = $pfxPasswordToggle.Checked
BaseUri = $baseUriBox.Text BaseUri = $baseUriBox.Text
Validation = $validationBox.Text Validation = $validationBox.Text
ValidationPort = $validationPortBox.Text ValidationPort = $validationPortBox.Text
@@ -1331,7 +1349,7 @@ $saveDefaultsBtn.Add_Click({
} }
Save-Defaults -Defaults $defaults Save-Defaults -Defaults $defaults
& $logAction "Defaults saved to $(Get-DefaultsPath)." & $logAction "Defaults saved to $(Get-DefaultsPath)."
if (-not [string]::IsNullOrWhiteSpace($pfxPasswordBox.Text)) { if ($pfxPasswordToggle.Checked -and -not [string]::IsNullOrWhiteSpace($pfxPasswordBox.Text)) {
& $logAction "Warning: PFX password is stored in plaintext." & $logAction "Warning: PFX password is stored in plaintext."
} }
}) })
@@ -1371,7 +1389,8 @@ $runBtn.Add_Click({
$outputType = $outputTypeBox.SelectedItem.ToString() $outputType = $outputTypeBox.SelectedItem.ToString()
$outputPath = $outputPathBox.Text.Trim() $outputPath = $outputPathBox.Text.Trim()
if (-not $outputPath) { throw "Output path is required." } if (-not $outputPath) { throw "Output path is required." }
if ($outputType -eq "PFX" -and [string]::IsNullOrWhiteSpace($pfxPasswordBox.Text)) { $usePfxPassword = $outputType -eq "PFX" -and $pfxPasswordToggle.Checked
if ($usePfxPassword -and [string]::IsNullOrWhiteSpace($pfxPasswordBox.Text)) {
throw "PFX password is required." throw "PFX password is required."
} }
@@ -1443,7 +1462,7 @@ $runBtn.Add_Click({
-HostFqdns @($entry.Fqdn) ` -HostFqdns @($entry.Fqdn) `
-OutputType $outputType ` -OutputType $outputType `
-OutputPath $outputPath ` -OutputPath $outputPath `
-PfxPassword $pfxPasswordBox.Text ` -PfxPassword ($(if ($usePfxPassword) { $pfxPasswordBox.Text } else { "" })) `
-BaseUri $baseUriBox.Text.Trim() ` -BaseUri $baseUriBox.Text.Trim() `
-Validation $validationBox.Text.Trim() ` -Validation $validationBox.Text.Trim() `
-ValidationPort $validationPortBox.Text.Trim() ` -ValidationPort $validationPortBox.Text.Trim() `
@@ -1458,7 +1477,7 @@ $runBtn.Add_Click({
-HostFqdns $hostList ` -HostFqdns $hostList `
-OutputType $outputType ` -OutputType $outputType `
-OutputPath $outputPath ` -OutputPath $outputPath `
-PfxPassword $pfxPasswordBox.Text ` -PfxPassword ($(if ($usePfxPassword) { $pfxPasswordBox.Text } else { "" })) `
-BaseUri $baseUriBox.Text.Trim() ` -BaseUri $baseUriBox.Text.Trim() `
-Validation $validationBox.Text.Trim() ` -Validation $validationBox.Text.Trim() `
-ValidationPort $validationPortBox.Text.Trim() ` -ValidationPort $validationPortBox.Text.Trim() `