Category Archives: ssl

How to import a private key and certificate into a java keystore

Convert to PEM format via openssl :

openssl pkcs8 -topk8 -nocrypt -in key.pem -inform PEM -out key.der -outform DER
openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER

Import private key and cert via ImportKey class

Import the keystore generated above into your existing keystore :

keytool -v -importkeystore -srckeystore “C:keystore.ImportKey” -destkeystore “C:.keystore”

(optionally you can specify the alias via –srcalias and –destalias, note that an alias is unique within the keystore)

Sources :, and