Skip to content

Instantly share code, notes, and snippets.

@voxxit
Forked from michaelklishin/gist:2851251
Last active May 15, 2019 16:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voxxit/6b4f0be3aa9ad6f49106 to your computer and use it in GitHub Desktop.
Save voxxit/6b4f0be3aa9ad6f49106 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Downloads and installs the startssl CA certs into the global Java keystore
# on Alpine Linux.
#
# Check if JAVA_HOME is set
[ "$JAVA_HOME" = "" ] && echo "ERROR: JAVA_HOME must be set" && exit 1
# Check if cacerts file is present
[ ! -f $JAVA_HOME/jre/lib/security/cacerts ] && echo "ERROR: Java cacerts not found in JAVA_HOME" && exit 1
# Download the startssl certs
wget -q --continue http://www.startssl.com/certs/ca.crt
wget -q --continue http://www.startssl.com/certs/sub.class{1..4}.server.ca.crt
# Install certs into global keystore
cacerts=$JAVA_HOME/jre/lib/security/cacerts
keytool -import -trustcacerts -keystore $cacerts -storepass changeit -noprompt -alias startcom.ca -file ca.crt
for i in {1..4}; do
keytool -import -trustcacerts -keystore $cacerts -storepass changeit -noprompt \
-alias startcom.ca.sub.class$i -file sub.class$i.server.ca.crt
done
# Remove downloaded certs
rm -f ca.crt sub.class{1..4}.server.ca.crt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment