I was recently install some certificates into my local store and wanted to verify that they were working correctly. I put together a simple Java program that verifies the target sites can be loaded.


/**
* SSL Test -- tests that JVM is configured correctly to load an SSL certificate
*/
package com.meesqa.sample;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;

public class SSLTest
{

public static final String test1URL = "https://www.google.com/";
public static final String test2URL = "https://login.live.com/";

public static void testURL( String url )
{
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod( url );

try
{
client.executeMethod( method );

if( method.getStatusCode() == HttpStatus.SC_OK )
{
System.out.println( url + " access OK." );
}
else
{
System.out.println( url + " access FAILED." );
}
}
catch( Exception e )
{
System.out.println( url + " access FAILED with an exception: " + e.getMessage() );
}
}

public static void main( String[] args )
{
SSLTest.testURL( test1URL );
SSLTest.testURL( test2URL );
}

}

Running the program tests the 2 urls specified:

java com.meesqa.sample.SSLTest
https://www.google.com/ access OK.
https://login.live.com/ access OK.