Skip to content

Instantly share code, notes, and snippets.

@Firefishy
Forked from hedefalk/install-letsencrypt-in-jdk.sh
Last active September 1, 2022 10:40
Show Gist options
  • Select an option

  • Save Firefishy/109b0f1a90156f6c933a50fe40aa777e to your computer and use it in GitHub Desktop.

Select an option

Save Firefishy/109b0f1a90156f6c933a50fe40aa777e to your computer and use it in GitHub Desktop.

Revisions

  1. Firefishy revised this gist Apr 16, 2016. 1 changed file with 16 additions and 6 deletions.
    22 changes: 16 additions & 6 deletions install-letsencrypt-in-jdk.sh
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,31 @@
    #!/bin/bash
    set -e

    JAVA_HOME=${1-text}
    [ $# -eq 0 ] && { echo "Usage: sudo $0 \$(/usr/libexec/java_home -v '1.8*')" ; exit 1; }

    KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts

    wget https://letsencrypt.org/certs/isrgrootx1.pem
    wget https://letsencrypt.org/certs/letsencryptauthorityx1.der
    wget https://letsencrypt.org/certs/letsencryptauthorityx2.der
    wget https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.der
    wget https://letsencrypt.org/certs/lets-encrypt-x2-cross-signed.der
    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 -delete -alias isrgrootx1 -keystore $KEYSTORE -storepass changeit 2> /dev/null || true
    keytool -delete -alias isrgrootx2 -keystore $KEYSTORE -storepass changeit 2> /dev/null || true
    keytool -delete -alias letsencryptauthorityx1 -keystore $KEYSTORE -storepass changeit 2> /dev/null || true
    keytool -delete -alias letsencryptauthorityx2 -keystore $KEYSTORE -storepass changeit 2> /dev/null || true
    keytool -delete -alias letsencryptauthorityx3 -keystore $KEYSTORE -storepass changeit 2> /dev/null || true
    keytool -delete -alias letsencryptauthorityx4 -keystore $KEYSTORE -storepass changeit 2> /dev/null || true

    keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias isrgrootx1 -file isrgrootx1.pem
    keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias isrgrootx1 -file letsencryptauthorityx1.der
    keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias isrgrootx2 -file letsencryptauthorityx2.der
    keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias letsencryptauthorityx1 -file lets-encrypt-x1-cross-signed.der
    keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias letsencryptauthorityx2 -file lets-encrypt-x2-cross-signed.der
    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
    rm -f letsencryptauthorityx1.der letsencryptauthorityx2.der lets-encrypt-x1-cross-signed.der lets-encrypt-x2-cross-signed.der lets-encrypt-x3-cross-signed.der lets-encrypt-x4-cross-signed.der
  2. @hedefalk hedefalk revised this gist Apr 11, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-letsencrypt-in-jdk.sh
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ 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 idempontent
    # 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
  3. @hedefalk hedefalk revised this gist Apr 11, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-letsencrypt-in-jdk.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ keytool -delete -alias isrgrootx1 -keystore $KEYSTORE -storepass changeit 2> /de
    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 ~/Downloads/isrgrootx1.pem
    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

  4. @hedefalk hedefalk revised this gist Apr 11, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-letsencrypt-in-jdk.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    JAVA_HOME=${1-text}
    [ $# -eq 0 ] && { echo "Usage: $0 JAVA_HOME" ; exit 1; }
    [ $# -eq 0 ] && { echo "Usage: sudo $0 \$(/usr/libexec/java_home -v '1.8*')" ; exit 1; }

    KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts

  5. @hedefalk hedefalk revised this gist Apr 11, 2016. 2 changed files with 21 additions and 13 deletions.
    13 changes: 0 additions & 13 deletions install letsencrypt in jdk
    Original file line number Diff line number Diff line change
    @@ -1,13 +0,0 @@
    wget https://letsencrypt.org/certs/isrgrootx1.pem
    wget https://letsencrypt.org/certs/letsencryptauthorityx1.der

    sudo keytool -delete -alias letsencryptauthorityx1 -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit
    sudo keytool -delete -alias isrgrootx1 -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit

    sudo keytool -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -importcert -alias letsencryptauthorityx1 -file ~/Downloads/letsencryptauthorityx1.der
    Certificate was added to keystore

    sudo keytool -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -importcert -alias isrgrootx1 -file ~/Downloads/isrgrootx1.pem
    Certificate was added to keystore

    rm isrgrootx1.pem letsencryptauthorityx1.der
    21 changes: 21 additions & 0 deletions install-letsencrypt-in-jdk.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash

    JAVA_HOME=${1-text}
    [ $# -eq 0 ] && { echo "Usage: $0 JAVA_HOME" ; exit 1; }

    KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts

    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 idempontent
    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 ~/Downloads/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
  6. @hedefalk hedefalk created this gist Apr 11, 2016.
    13 changes: 13 additions & 0 deletions install letsencrypt in jdk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    wget https://letsencrypt.org/certs/isrgrootx1.pem
    wget https://letsencrypt.org/certs/letsencryptauthorityx1.der

    sudo keytool -delete -alias letsencryptauthorityx1 -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit
    sudo keytool -delete -alias isrgrootx1 -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit

    sudo keytool -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -importcert -alias letsencryptauthorityx1 -file ~/Downloads/letsencryptauthorityx1.der
    Certificate was added to keystore

    sudo keytool -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -importcert -alias isrgrootx1 -file ~/Downloads/isrgrootx1.pem
    Certificate was added to keystore

    rm isrgrootx1.pem letsencryptauthorityx1.der