March 06, 2018

Import PEM cert or key into your keystore

Easiest way I know to import a PEM format cert or key file into your Java keystore involves two steps.

1- Convert your PEM format certificate into DER format by using the following command syntax:
openssl x509 -outform der -in yourcert.pem -out yourcert.der

2- Import your resulting DER format certificate into your "cacerts" keystore using this syntax:
keytool -import -alias youralias -keystore cacerts -file yourcert.der
Share: