Skip to content

Commit 43eefa0

Browse files
author
Bob Pokorny
committed
Filtered the Private Key Password from view and improved error message when invalid CSP was used.
1 parent c1c3702 commit 43eefa0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

IISU/ImplementedStoreTypes/WinIIS/Management.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,10 @@ public string AddCertificate(string certificateContents, string privateKeyPasswo
298298
catch (Exception ex)
299299
{
300300
var failureMessage = $"Management job {_operationType} failed on Store '{_storePath}' on server '{_clientMachineName}' with error: '{LogHandler.FlattenException(ex)}'";
301+
var niceMessage = $"Management job {_operationType} failed on Store '{_storePath}' on server '{_clientMachineName}' with error: {ex.Message}";
301302
_logger.LogError(failureMessage);
302303

303-
throw new Exception (failureMessage);
304+
throw new Exception (niceMessage);
304305
}
305306
}
306307
public void RemoveIISCertificate(string thumbprint)

IISU/PowerShellScripts/WinCertScripts.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,13 @@ function Add-KFCertificateToStore{
227227
try {
228228
# Build certutil command to import the certificate with exportable private key and CSP
229229
$command = "certutil -f -p `"$PrivateKeyPassword`" -csp `"$CryptoServiceProvider`" -importpfx $StoreName `"$tempPfx`""
230+
$traceCommand = "certutil -f -p `"************`" -csp `"$CryptoServiceProvider`" -importpfx $StoreName `"$tempPfx`""
230231

231-
Write-Verbose "Running: $command"
232+
Write-Verbose "Running: $traceCommand"
232233
$output = Invoke-Expression $command
233234

234235
if ($LASTEXITCODE -ne 0) {
235-
throw "certutil failed with code $LASTEXITCODE. Output: $output"
236+
throw "certutil failed with code $LASTEXITCODE. `nOutput: $output `nMake sure there is no cryptographic mismatch and the CSP supports the imported PFX.`n"
236237
}
237238

238239
# Get latest cert with private key in the store

0 commit comments

Comments
 (0)