HTTPComponent HttpClient SSLSocketFactory
As promissed additional to last post, adding some sample code for the 'geeks' :)
try {
System.out.println("Loading Truststore with trusted public certificate");
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
try {
trustStore.load([truststore],
"password".toCharArray());
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
System.out.println("Loading Keystore with private key to identify the client");
KeyStore keystore = KeyStore.getInstance("pkcs12");
try {
keystore.load([keystore],
"password".toCharArray());
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
SSLSocketFactory socketFactory = new SSLSocketFactory(keystore, "password", trustStore);
Scheme sch = new Scheme("https", 443, socketFactory);
defaultHttpClient.getConnectionManager().getSchemeRegistry().register(sch);
HttpGet httpget = new HttpGet('https://2waysslservice/something');
HttpResponse response = defaultHttpClient.execute(httpget);
HttpEntity entity = response.getEntity();
System.out.println("Do what you like with the response");
}















