Skip to content

Instantly share code, notes, and snippets.

@djraw
Created March 3, 2018 17:04
Show Gist options
  • Save djraw/d95416be429049363be9a1d06ae69d16 to your computer and use it in GitHub Desktop.
Save djraw/d95416be429049363be9a1d06ae69d16 to your computer and use it in GitHub Desktop.
Export private key from a Java Keytool keystore to pem
Use Java keytool to convert from JKS to P12...
Export from keytool's proprietary format (called "JKS") to standardized format PKCS #12:
keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12 -srcalias <jkskeyalias> -deststorepass <password> -destkeypass <password>
...then use openssl to export from P12 to PEM
Export certificate using openssl:
openssl pkcs12 -in keystore.p12 -nokeys -out cert.pem
Export unencrypted private key:
openssl pkcs12 -in keystore.p12 -nodes -nocerts -out key.pem
@hrstoyanov
Copy link

how about without using openssl?

@djraw
Copy link
Author

djraw commented Jun 3, 2021

This is just a note for me how to convert with openssl. If you need another solution, please use Google.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment