Skip to content

Instantly share code, notes, and snippets.

@cadyyan
Last active August 12, 2019 06:27
Show Gist options
  • Select an option

  • Save cadyyan/8f377d36e3f815e501be84e38a685452 to your computer and use it in GitHub Desktop.

Select an option

Save cadyyan/8f377d36e3f815e501be84e38a685452 to your computer and use it in GitHub Desktop.

Revisions

  1. cadyyan revised this gist Apr 1, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lets-encrypt-java-fix.sh
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ import_cert() {
    fi

    keytool -importcert -noprompt -trustcacerts \
    -storepass changeit \
    -keystore "$KEYSTORE" -storepass changeit \
    -alias "$CERT_ALIAS" -file "$CERT"
    }

  2. cadyyan revised this gist Mar 31, 2016. 1 changed file with 34 additions and 6 deletions.
    40 changes: 34 additions & 6 deletions lets-encrypt-java-fix.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,25 @@
    #!/bin/bash

    download_cert() {
    URL="https://letsencrypt.org/certs/${1}.der"

    wget --quiet --no-clobber $URL
    }

    import_cert() {
    CERT=$1
    CERT_ALIAS=$2

    if [ -z "$CERT_ALIAS" ];
    then
    CERT_ALIAS=${CERT%%.*}
    fi

    keytool -importcert -noprompt -trustcacerts \
    -storepass changeit \
    -alias "$CERT_ALIAS" -file "$CERT"
    }

    if [ -z "$JAVA_HOME" ];
    then
    echo "JAVA_HOME not set"
    @@ -15,15 +35,23 @@ then
    exit 1
    fi

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

    echo "Downloading certificates..."
    download_cert isrgrootx1
    download_cert lets-encrypt-x1-cross-signed
    download_cert lets-encrypt-x2-cross-signed
    download_cert lets-encrypt-x3-cross-signed
    download_cert lets-encrypt-x4-cross-signed

    echo "Importing root certificate..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-isrgrootx1 -file isrgrootx1.der
    import_cert isrgrootx1.der lets-encrypt-isrgrootx1
    echo "Import cross-signed certificate 1..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-x1-cross-signed -file lets-encrypt-x1-cross-signed.der
    import_cert lets-encrypt-x1-cross-signed.der
    echo "Import cross-signed certificate 2..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-x2-cross-signed -file lets-encrypt-x2-cross-signed.der
    import_cert lets-encrypt-x2-cross-signed.der
    echo "Import cross-signed certificate 3..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-x3-cross-signed -file lets-encrypt-x3-cross-signed.der
    import_cert lets-encrypt-x3-cross-signed.der
    echo "Import cross-signed certificate 4..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-x4-cross-signed -file lets-encrypt-x4-cross-signed.der
    import_cert lets-encrypt-x4-cross-signed.der

  3. cadyyan created this gist Mar 31, 2016.
    29 changes: 29 additions & 0 deletions lets-encrypt-java-fix.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/bin/bash

    if [ -z "$JAVA_HOME" ];
    then
    echo "JAVA_HOME not set"
    exit 1
    fi

    read -p "Updating keystore for JRE located at $JAVA_HOME. Is this correct? [y/N]: " -n 1 -r
    echo

    if [[ ! $REPLY =~ ^[Yy]$ ]]
    then
    echo "Cancelled"
    exit 1
    fi

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

    echo "Importing root certificate..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-isrgrootx1 -file isrgrootx1.der
    echo "Import cross-signed certificate 1..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-x1-cross-signed -file lets-encrypt-x1-cross-signed.der
    echo "Import cross-signed certificate 2..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-x2-cross-signed -file lets-encrypt-x2-cross-signed.der
    echo "Import cross-signed certificate 3..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-x3-cross-signed -file lets-encrypt-x3-cross-signed.der
    echo "Import cross-signed certificate 4..."
    keytool -importcert -noprompt -trustcacerts -keystore "$KEYSTORE" -storepass changeit -alias lets-encrypt-x4-cross-signed -file lets-encrypt-x4-cross-signed.der