Created
April 23, 2019 16:11
-
-
Save zaneclaes/84aa90cd9dcf22e721a32f99f000d8cf to your computer and use it in GitHub Desktop.
Converts a letsencrypt certificate into a JKS file.
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
#!/bin/bash | |
# Converts a letsencrypt certificate into a JKS file. | |
# Usage: | |
# ./certbot_jks.sh [domain_name] [email] | |
le_dir="/etc/letsencrypt" | |
domain=${1} | |
email=${2} | |
OUT_DIR=${le_dir}/live/${domain} | |
GATE_EXPORT_PASSWORD=test1234 | |
JKS_PASSWORD=abcd1234 | |
cd $OUT_DIR | |
rm -rf gate.p12 || true | |
rm -rf gate.jks || true | |
openssl pkcs12 -export -clcerts -in cert.pem \ | |
-inkey privkey.pem -out gate.p12 -name gate \ | |
-password pass:${GATE_EXPORT_PASSWORD} | |
echo 'y' | keytool -importkeystore \ | |
-srckeystore gate.p12 \ | |
-srcstoretype pkcs12 \ | |
-srcalias gate \ | |
-destkeystore gate.jks \ | |
-destalias gate \ | |
-deststoretype pkcs12 \ | |
-deststorepass ${JKS_PASSWORD} \ | |
-destkeypass ${JKS_PASSWORD} \ | |
-srcstorepass ${GATE_EXPORT_PASSWORD} | |
keytool -import -trustcacerts -alias ca -file chain.pem -keystore gate.jks -storepass ${JKS_PASSWORD} -noprompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment