Skip to content

Instantly share code, notes, and snippets.

@yogsototh
Created February 10, 2016 12:50
Show Gist options
  • Save yogsototh/8bd35463f2a1ef0e820e to your computer and use it in GitHub Desktop.
Save yogsototh/8bd35463f2a1ef0e820e to your computer and use it in GitHub Desktop.
Add Java Certificate

Add Java Cacert

Use the preceeding script when you get

SSLHandshakeException javax.net.ssl.SSLHandshakeException: General SSLEngine problem

You generally need to add the certificate for the website you want to add.

add-java-cert.sh my.website.org
#!/usr/bin/env zsh
url=$1
port=443
tmpfile=/tmp/certfile.$$.txt
openssl s_client -connect $url:$port 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $tmpfile
JAVA_HOME=$(/usr/libexec/java_home)
print -P -- "%BDEFAULT PASSWORD IS: 'changeit'%b"
sudo $JAVA_HOME/bin/keytool -import -alias "$url" -file $tmpfile -keystore $JAVA_HOME/lib/security/cacerts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment