Standalone Java SSL Client
Simple standalone Java SSL client using Apache Commons HTTPClient library:
package au.com.valton.sslclient;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;public class SSLClientMain {
public static void main(String[] args) {
System.setProperty(”javax.net.ssl.keyStore”, “local_keystore.p12″);
System.setProperty(”javax.net.ssl.keyStorePassword”, “keystore_password”);
System.setProperty(”javax.net.ssl.keyStoreType”, “PKCS12″);System.setProperty(”javax.net.ssl.trustStore”, “local_truststore.p12″);
System.setProperty(”javax.net.ssl.trustStorePassword”, “trustore_password”);
System.setProperty(”javax.net.ssl.trustStoreType”, “PKCS12″);System.setProperty(”javax.net.debug”, “ssl”);
HttpMethod httpGet = new GetMethod();
HttpClient httpClient = new HttpClient();try {
httpClient.executeMethod(httpGet);
System.out.println(new String(httpGet.getResponseBody()));
} catch (Exception e) {
e.printStackTrace();
}
}
}