How to convert pem file to jks?

We might be having .pem file but application accepts only .jks file then we need to convert them into jks format. Let see how to achieve this. Generally .pem file has both private key and certificate but in some case both are in separate files.In that scenario we need merge them in single file.

cat serverkey.pem servercert.pem | openssl pkcs12 -export -out combinedcert.p12

Now lets import the certificate into keystore using java keytool

keytool -importkeystore -srckeystore combinedcert.p12 -srcstoretype pkcs12 -destkeystore myfile.jks

That's all , we are done.


Post a Comment

Powered by Blogger.