How can I create SSL handshake using BouncyCastle APIs

Monday, June 30, 2014

I have a java code that uses the default java libraries to create ssl handshake with a given domain name.

public class SimpleSSL {

public static void main(String args []) throws UnknownHostException, IOException
SSLSocket socket=null;
SSLSocketFactory factory=null;
factory = HttpsURLConnection.getDefaultSSLSocketFactory();

//NOTE: put the ssl domain name e.g. ""
String host="";
int port=443;
socket = (SSLSocket) factory.createSocket(host, port); //add the domain name that you want to scan here
socket.startHandshake(); // start the handshake
System.out.println("Handshake Done");

}//end main


I need to make the ssl handshake using bouncy castle APIs. I need to change the set of cipher suites so I want to make my ssl handshake with a specific cipher (that the default java library does not support). I also want to extract some variables from the SSL certificate. In default java I was able to do this simply. But now I am lost!! For example, what is the class name that I can use to define an X509 certificate?

I did not find proper documentation or code samples that can help me. I need a page similar to hava docs pages that I find all the classes with their functions. Can you help me?