The selected answer apparently does not work anymore in 2019 (at least for me).
I was trying to export a certificate using openssl (version 1.1.0) and the parameter -password
doesn't work.
According to that link in the original answer (the same info is in man openssl
), openssl has two parameter for passwords and they are -passin
for the input parts and -passout
for output files.
For the -export
command, I used -passin
for the password of my key file and -passout
to create a new password for my P12 file.
So the complete command without any prompt was like below:
openssl pkcs12 -export -in /tmp/MyCert.crt -inkey /tmp/MyKey.key -out /tmp/MyP12.p12 -name alias -passin pass:keypassphrase -passout pass:certificatepassword
If you does not want a password, you can use pass:
like below:
openssl pkcs12 -export -in /tmp/MyCert.crt -inkey /tmp/MyKey.key -out /tmp/MyP12.p12 -name alias -passin pass: -passout pass:
It will works fine with a key without password and the output certificate will be created without password too.