Export Private Key From a Java Keytool Keystore

Since Java verion 6, you can import/export private keys into PKCS#12 (.p12) files using keytool, using -importkeystore (not available in previous versions).

The PKCS12 keystore type is also supported as a standard keystore type in the default Oracle/Sun security provider.

 

Once you have the p12 file, you can export the keys using openssl.

Export certificate using openssl:

Export unencrypted private key: