Last active
August 27, 2019 12:16
-
-
Save RecuencoJones/80bf2c22ec859727f158102fcd0f79f2 to your computer and use it in GitHub Desktop.
JKS -> PEM & CRT + KEY
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
#!/usr/bin/env bash | |
if [[ -z $SUBJECT ]] && [[ -z $1 ]] ; then | |
read -p "Subject: " SUBJECT | |
fi | |
if [[ -z $PASSPHRASE ]] && [[ -z $2 ]] ; then | |
read -p "Passphrase: " PASSPHRASE | |
fi | |
subject=${SUBJECT:-$1} | |
passphrase=${PASSPHRASE:-$2} | |
keytool -importkeystore \ | |
-srckeystore $subject.jks \ | |
-destkeystore $subject.p12 \ | |
-srcalias $subject \ | |
-srcstoretype jks \ | |
-deststoretype pkcs12 \ | |
-srcstorepass $passphrase \ | |
-deststorepass $passphrase \ | |
-no-prompt | |
openssl pkcs12 -in $subject.p12 -out $subject.pem -passin pass:$passphrase -passout pass:$passphrase | |
openssl pkey -in $subject.pem -out private.key -passin pass:$passphrase | |
openssl x509 -in $subject.pem -out public.crt -passin pass:$passphrase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment