Created
May 29, 2016 13:36
-
-
Save valtoni/52fbd82a95fc9f47787a7a83b337dd90 to your computer and use it in GitHub Desktop.
Script to export certificate and private key from jks store
This file contains hidden or 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
| #!/bin/bash | |
| FILE=$1 | |
| OUTPUT_NAME=$2 | |
| # Export to PKCS12 format | |
| keytool -importkeystore -srckeystore "$FILE" -destkeystore "$OUTPUT_NAME".p12 -deststoretype PKCS12 | |
| # Export certificate in pem format | |
| openssl pkcs12 -in "$OUTPUT_NAME".p12 -nokeys -out "$OUTPUT_NAME"_cert.pem | |
| # Export certificate in x509 format | |
| openssl x509 -outform der -in "$OUTPUT_NAME"_cert.pem -out "$OUTPUT_NAME"_cert.crt | |
| # Export unencripted key in pem format | |
| openssl pkcs12 -in "$OUTPUT_NAME".p12 -nodes -nocerts -out "$OUTPUT_NAME"_key.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment