Created
July 27, 2022 12:43
-
-
Save nipunthathsara/94c25afb177a39bf52b3b3cff6f5cca8 to your computer and use it in GitHub Desktop.
Extract private/public keys from JKS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 1 | |
# Convert JKS to PKCS12 | |
keytool -importkeystore -srckeystore <SRC_KEYSTORE.JKS> -srcstorepass <SRC_KEYSTORE_PASSWORD> -srckeypass <SRC_KEY_PASSWORD> -srcalias <SRC_KEY_ALIAS> -destalias <DST_KEY_ALIAS> -destkeystore temp.p12 -deststoretype PKCS12 -deststorepass <DST_STORE_PASSWORD> -destkeypass <DST_STORE_PASSWORD> | |
# <DST_STORE_PASSWORD> <DST_STORE_PASSWORD> Should be the same for PKCS12 keystore type. | |
# Step 2 | |
# Extract private key | |
openssl pkcs12 -in temp.p12 -nodes -nocerts -out private_key.pem | |
# Step 3 | |
# Extract public key | |
openssl pkcs12 -in temp.p12 -nokeys -out cert.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment