sebastiandaschner blog


Import self-signed SSL certificate in Java

#java monday, february 09, 2015

While developing web services you might get into the situation where an SSL certificate is needed. Java does not allow self-signed certificates per default which results in an SSLHandshakeException. To overcome this you could globally accept all certificates. But sometimes it’s a better solution to install the temporary development certificate into Java’s keystore.

Therefore you add the desired certificate via keytool:

cd <JDK_HOME>/jre/lib/security
keytool -import -keystore cacerts -file cert.crt

The default password for the Java keystore is changeit ;-)

 

Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java: