I want to use openssl pkcs12 to convert lots of pem files into pfx files - but is it possible to pass in a password via the command line?
I have quite a lot of pem files:
So I want to enter a password into Powershell once that is then used to pass in via the command line -> rather than have to keep manually typing it in twice for each pem.
Is this even possible?
I have tried -pass pass: which does not work:-
openssl pkcs12 -export -out outfile.pfx -inkey pem.key -in pem.cert -pass pass: somePassword
FYI:
This is my current Powershell script:-
$TopLevel = "C:\CertConversion\"
$OutputFolder = "$TopLevel"+"Processed\"
$CertFolder = "$TopLevel"+"CertsToProcess\"
$PasswordIWantToUse = Read-Host "PEM Conversion - Please enter a password"
$list = Get-ChildItem -Path $CertFolder
ForEach($i in $list)
{
$pemName = $i.Name
$list = Get-ChildItem -Path $CertFolder
$simpleName = $pemName.Replace(".pem","")
$OutputFile = "$OutputFolder"+"$simpleName"+".pfx"
openssl pkcs12 -export -out $OutputFile -inkey "$CertFolder$pemName" -in "$CertFolder$pemName"
}
Note:
For each pem I currently get prompted "Enter Export Password:" then re-prompted "Verifying - Enter Export Password:"
I gave this another go - based on suggestions in the answer from @JMusgrove
The answer turned out to be: -password pass:
So in full:
openssl pkcs12 -export -out $OutputFile -inkey "$CertFolder$pemName" -in "$CertFolder$pemName" -password pass:$PasswordIWantToUse