Skip to content

Instantly share code, notes, and snippets.

@tdomzal
Last active August 29, 2015 14:23
Show Gist options
  • Save tdomzal/a5fcec9e9d0a0892f844 to your computer and use it in GitHub Desktop.
Save tdomzal/a5fcec9e9d0a0892f844 to your computer and use it in GitHub Desktop.
Bash script to download InstallCert.jar tool and add https certificate into ${JAVA_HOME}/jre/lib/security
#!/bin/bash
echoerr() { echo "$@" 1>&2; }
if [ $# -ne 1 ]; then
echo "Illegal number of parameters"
echo "Usage: "
echo " $0 <hostname:port>"
exit 1
fi
SSL_HOST="$1"
[ -d $HOME/bin ] || mkdir -p $HOME/bin
if [ ! -f $HOME/bin/InstallCert.jar ]; then
# http://s-n-ushakov.blogspot.com/2013/11/yet-another-installcert-for-java-now.html
wget 'https://drive.google.com/uc?export=download&id=0B2nLiheurgV7Z1hxc3hMMGo0NWc' -O $HOME/bin/installcert-usn-20140115.zip && \
unzip $HOME/bin/installcert-usn-20140115.zip installcert-usn-20140115/installcert-usn-20140115.jar -d $HOME/bin && \
mv $HOME/bin/installcert-usn-20140115/installcert-usn-20140115.jar $HOME/bin/InstallCert.jar && \
rm -f $HOME/bin/installcert-usn-20140115.zip && \
rm -rf $HOME/bin/installcert-usn-20140115 || {
echoerr "Unable to retreive InstallCert.jar"
exit 1
}
fi
[ -d "${JAVA_HOME}/jre/lib/security" ] || {
echoerr "No such directory ${JAVA_HOME}/jre/lib/security"
exit 1
}
cd ${JAVA_HOME}/jre/lib/security
java -Djsse.enableSNIExtension=false -jar $HOME/bin/InstallCert.jar "${SSL_HOST}"
mkdir $HOME/bin
cd bin
wget https://gist.githubusercontent.com/tdomzal/a5fcec9e9d0a0892f844/raw/41f981051bc1483fa444851995e098a627604691/java-install-cert.sh
chmod u+x java-install-cert.sh
./java-install-cert.sh somehost:443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment