Unfortunately none of the answers posted thus far are correct, as they just supply a blank password as opposed to no password, which means that you will still get prompted for a password in the first place.
For the sake of keeping everything together in one place, I'll copy @slm's post with some slight ammendments;
- PASSWORD is your current password
- YourPKCSFile is the file you want to convert
- NewPKCSWithoutPassphraseFile is the target file for the PKCS12 without passphrase
First, extract the certificate:
$ openssl pkcs12 -clcerts -nokeys -in "YourPKCSFile" -out certificate.crt \
-password pass:PASSWORD -passin pass:PASSWORD
Second, the CA (issuer) certificate:
$ openssl pkcs12 -cacerts -nokeys -in "YourPKCSFile" -out ca-cert.ca \
-password pass:PASSWORD -passin pass:PASSWORD
Now, the private key:
$ openssl pkcs12 -nocerts -in "YourPKCSFile" -out private.key -password \
pass:PASSWORD -passin pass:PASSWORD -passout pass:TemporaryPassword
Now remove the passphrase:
$ openssl rsa -in private.key -out "NewKeyFile.key" -passin pass:TemporaryPassword
Put things together for the new PKCS-File:
Bash:
$ cat "NewKeyFile.key" "certificate.crt" "ca-cert.ca" > PEM.pem
CMD:
$ type "NewKeyFile.key" "certificate.crt" "ca-cert.ca" > PEM.pem
And create the new file:
$ openssl pkcs12 -export -nodes -CAfile ca-cert.ca -in PEM.pem
-out "NewPKCSWithoutPassphraseFile.p12" -passout pass:
./remove_pass_from_cert.sh YourCertName YourCertPass