Samples JDK
ClientConnectionTest.java
1 package com.freemindcafe.https.clientauth;
2 
3 import java.io.IOException;
4 
5 import javax.net.ssl.SSLSocketFactory;
6 import static com.freemindcafe.utils.FileSystemUtils.currentDir;
7 
8 import org.apache.commons.httpclient.HttpClient;
9 import org.apache.commons.httpclient.HttpException;
10 import org.apache.commons.httpclient.URI;
11 import org.apache.commons.httpclient.methods.GetMethod;
12 
13 
15 {
16  static
17  {
18  System.setProperty("javax.net.ssl.trustStore", currentDir()+"/src/com/freemindcafe/https/clientauth/clientkeystore.jks");
19  System.setProperty("javax.net.ssl.trustStorePassword", "password");
20  System.setProperty("javax.net.ssl.keyStore", currentDir()+"/src/com/freemindcafe/https/clientauth/clientkeystore.jks");
21  System.setProperty("javax.net.ssl.keyStorePassword", "password");
22  System.setProperty("javax.net.debug", "ssl:handshake");
23  }
24 
25  public static void main(String[] args) throws HttpException, IOException
26  {
27  HttpClient client = new HttpClient();
28  GetMethod method = new GetMethod();
29  //if you are not redirecting you can use port as localhost:8443
30  method.setURI(new URI("https://localhost:443", false));
31  //method.setURI(new URI("https://nikhil.emeter.com:443", false));
32  client.executeMethod(method);
33  System.out.println(method.getResponseBodyAsString());
34  }
35 }