Skip to content

Instantly share code, notes, and snippets.

@NjengaFelix
Created May 25, 2023 10:39
Show Gist options
  • Save NjengaFelix/021fe594c29b58be00807b26c69d778d to your computer and use it in GitHub Desktop.
Save NjengaFelix/021fe594c29b58be00807b26c69d778d to your computer and use it in GitHub Desktop.
How to extract a private key from a java keystore
#First save the key in a p.12 file
#The p.12 file is password protected it shall prompt you to key in a new password
#You shall require to also key in the keystore password
keytool -v -importkeystore -srckeystore /path/to/keystore.jks -srcalias <alias> -destkeystore /path/to/output.p12 -deststoretype PKCS12
#Use openssl to store the private-key in a .pem file
openssl pkcs12 -in /path/to/output.p12 -out /path/to/private-key.pem -nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment