1

I would like to convert certificates automatically from pfx to pem via powershell.

So far i can start openssl and convert it. When you start converting it askes for the pfx password

$processStartInfo = New-Object System.Diagnostics.ProcessStartInfo
$processStartInfo.FileName = "openssl.exe"
$processStartInfo.RedirectStandardError = $true
$processStartInfo.RedirectStandardOutput = $true
$processStartInfo.UseShellExecute = $false
$processStartInfo.Arguments = "pkcs12 -in cert.pfx -nocerts -out privateKey.pem -nodes"
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $processStartInfo
$process.Start() | Out-Null
$process.WaitForExit()
$standardError = $process.StandardError.ReadToEnd()
if ($process.ExitCode) {
   Write-Error $standardError
} else {
   Write-Host $standardError
}

Right now i would get a pop up for the password How could automatically add this in this ps script

Kermit Christmas
  • 113
  • 2
  • 15

0 Answers0