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.
$ openssl pkcs12 -export -out cert.p12 -in cert.pem -inkey key.pem
Enter Export Password:
Verifying - Enter Export Password:
No password for cert.p12
$ openssl pkcs12 -export -out cert.p12 -in cert.pem -inkey key.pem -passout pass: -nokeys
Password 123 for cert.p12
$ openssl pkcs12 -export -out cert.p12 -in cert.pem -inkey key.pem -passout pass: 123
More helps.
$ openssl pkcs12 --help
pem files are OK, but I recive a error
Could not display example.com.p12
Reason: Could not parse invalid or corrupted data.
Good Day Sir! How do you convert .pem file that also contains the private key to .p12 file?
Thank you for your help, it helped a lot
How can do in java code ?
Thanks a lot! This is what I’ve been looking for.