How to Export Private Key from Java Keystore

oneIAM
1 min readMar 24, 2019

--

  1. First you have to convert .jks into .p12 format.

keytool -importkeystore -srckeystore <source keystore>.jks -srcstorepass <source keystore password> -srckeypass <source key password> -srcalias <source alias> -destalias <destination alias> -destkeystore <destination keystore>.p12 -deststoretype PKCS12 -deststorepass <destination keystore password> -destkeypass <destination key password>

EX:
keytool -importkeystore -srckeystore wso2carbon.jks -srcstorepass wso2carbon -srckeypass wso2carbon -srcalias wso2carbon -destalias wso2carbon -destkeystore identity.p12 -deststoretype PKCS12 -deststorepass wso2carbon -destkeypass wso2carbon

2. Export private key from .p12 keystore

openssl pkcs12 -in <key store>.p12 -nodes -nocerts -out <some name>.pem

EX:
openssl pkcs12 -in identity.p12 -nodes -nocerts -out private_key.pem

3. Now you can open private_key.pem from text editor and check private key in between BEGIN PRIVATE KEY and END PRIVATE KEY

--

--

oneIAM
oneIAM

Written by oneIAM

One-stop solution for all your enterprise identity and access management requirements

Responses (2)