org.freshcookies.security.cert
Class SSLHelper

java.lang.Object
  extended by org.freshcookies.security.cert.SSLHelper

public class SSLHelper
extends java.lang.Object

Extracts SSL certificates from a specified webserver and optionally adds them to the JSSE truststore.


Field Summary
protected static int SSL_PORT
          Default SSL port.
 
Constructor Summary
SSLHelper()
          Constructs a new SSLHelper.
 
Method Summary
static java.security.cert.Certificate[] extractSSLCertificates(java.lang.String hostname, int port)
          Helper method that connects to a specified host using SSL and extracts the server's peer certificates.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SSL_PORT

protected static final int SSL_PORT
Default SSL port.

See Also:
Constant Field Values
Constructor Detail

SSLHelper

public SSLHelper()
Constructs a new SSLHelper.

Method Detail

extractSSLCertificates

public static java.security.cert.Certificate[] extractSSLCertificates(java.lang.String hostname,
                                                                      int port)
Helper method that connects to a specified host using SSL and extracts the server's peer certificates. To do this, a new SSLContext is created using a "null" trust manager that accepts all peer SSL certificates as trusted. The null trust manager is provided by the method nullTrustManager. Note that in the array of Certificates returned by this method, the first certficate is the server's own certificate; the ones that follow are the certificate authorities in the chain.

Parameters:
hostname -
Returns:
the remote host's chain of SSL certificates

main

public static void main(java.lang.String[] args)