Skip to content

Instantly share code, notes, and snippets.

@thiyagaraj
Last active November 28, 2023 23:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiyagaraj/c4cde2c1257807a3126c to your computer and use it in GitHub Desktop.
Save thiyagaraj/c4cde2c1257807a3126c to your computer and use it in GitHub Desktop.
Convert jks/java keystore and get public and private keys as pem

Convert jks and get public and private keys out:

keytool -importkeystore -srckeystore default.keystore -destkeystore new-store.p12 -deststoretype PKCS12

  • Gives new-store.p12

openssl pkcs12 -in new-store.p12 -nokeys -out public.pem

  • Gives public key as public.pem

openssl pkcs12 -in new-store.p12 -nodes -nocerts -out private.pem

  • Gives private key as private.pem

Export jks public key as a pem file

keytool -exportcert -alias selfsigned -keypass password -keystore test-user.jks -rfc -file test-user.pem

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