2.12.11

Java SSL

If you want to establish an SSL connection in Java you have to set the following properties:

 System.setProperty("javax.net.ssl.keyStore", "mykestore");
 System.setProperty("javax.net.ssl.keyStorePassword", "password");
 System.setProperty("javax.net.ssl.trustStore", "cacerts");
 System.setProperty("javax.net.ssl.trustStorePassword", "changeit");

The keystore is a storage for the cryptographic keys and certificates.
The truststore holds the trusted sources, so Java knows to which sources it is allowed to talk to.
If you want to use a client identity certificate instead of the keystore, you can use the following property, to change the type e.g. pkcs12
System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");

The by Java provided tool for handling keystores and truststores is called
%JAVA_HOME%/bin/keytool

If you want to monitor the SSL traffic use the following runtime option
-Djavax.net.debug=all

No comments:

Post a Comment