Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipebn/54ef71bb5309554f0571eef627e65a8a to your computer and use it in GitHub Desktop.
Save felipebn/54ef71bb5309554f0571eef627e65a8a to your computer and use it in GitHub Desktop.
Shell script to update a keystore with lets encrypt cross signatures
#!/bin/bash
#Updates a keystore with lets encrypt cross signatures
[ $# -eq 0 ] && { echo "Usage: $0 <path to keystore>" ; exit 1; }
KEYSTORE=$1
wget https://letsencrypt.org/certs/isrgrootx1.pem
wget https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.der
wget https://letsencrypt.org/certs/lets-encrypt-x4-cross-signed.der
# to be idempotent
keytool -delete -alias isrgrootx1 -keystore $KEYSTORE -storepass changeit 2> /dev/null
keytool -delete -alias letsencryptauthorityx3 -keystore $KEYSTORE -storepass changeit 2> /dev/null
keytool -delete -alias letsencryptauthorityx4 -keystore $KEYSTORE -storepass changeit 2> /dev/null
keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias isrgrootx1 -file isrgrootx1.pem
keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias letsencryptauthorityx3 -file lets-encrypt-x3-cross-signed.der
keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias letsencryptauthorityx4 -file lets-encrypt-x4-cross-signed.der
rm isrgrootx1.pem lets-encrypt-x3-cross-signed.der lets-encrypt-x4-cross-signed.der
@felipebn
Copy link
Author

I've forked the original to keep it and change the script to be able to point out which keystore should be updated.

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