Skip to content

Instantly share code, notes, and snippets.

@meiwin
Created June 12, 2012 03:19
Show Gist options
  • Save meiwin/2914678 to your computer and use it in GitHub Desktop.
Save meiwin/2914678 to your computer and use it in GitHub Desktop.
[java] Https connection system properties for connection to server with self-signed certificate
// keyStore (client cert)
System.setProperty("javax.net.ssl.keyStoreType" , "pkcs12"); // corresponds to `.keyStore`
System.setProperty("javax.net.ssl.keyStore" , "clientcert.p12");
System.setProperty("javax.net.ssl.keyStorePassword" , "password"); //
// trustStore (server cert)
System.setProperty("javax.net.ssl.trustStoreType" , "jks"); // corresponds to `.trustStore`
System.setProperty("javax.net.ssl.trustStore" , "servercert.keystore"); // path to server truststore, when the server cert is imported into
System.setProperty("javax.net.ssl.trustStorePassword", "password");
// The above code can be substituted with below parameters when starting the jvm
/**
-Djavax.net.ssl.keyStoreType=pkcs12
-Djavax.net.ssl.trustStoreType=jks
-Djavax.net.ssl.keyStore=clientcertificate.p12
-Djavax.net.ssl.trustStore=gridserver.keystore
-Djavax.net.debug=ssl # very verbose debug
-Djavax.net.ssl.keyStorePassword=$PASS
-Djavax.net.ssl.trustStorePassword=$PASS
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment