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