SSL – Convert PEM and private key to PKCS#12

For the SSL certificate, Java doesn’t understand PEM format, and it supports JKS or PKCS#12. This article shows you how to use OpenSSL to convert the existing pem file and its private key into a single PKCS#12 or .p12 file.

Solution

Convert cert.pem and private key key.pem into a single cert.p12 file, key in the key-store-password manually for the .p12 file.

Terminal

$ openssl pkcs12 -export -out cert.p12 -in cert.pem -inkey key.pem

Enter Export Password:
Verifying - Enter Export Password:

No password for cert.p12

Terminal

$ openssl pkcs12 -export -out cert.p12 -in cert.pem -inkey key.pem -passout pass: -nokeys

Password 123 for cert.p12

Terminal

$ openssl pkcs12 -export -out cert.p12 -in cert.pem -inkey key.pem -passout pass: 123

More helps.

Terminal

$ openssl pkcs12 --help

References

author image

mkyong

Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities. Read all published posts by

Comments

avatar