Java tutorial
import javax.net.ssl.HandshakeCompletedEvent; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; class MyHandshakeListener implements HandshakeCompletedListener { public void handshakeCompleted(HandshakeCompletedEvent e) { System.out.println("Using cipher suite: " + e.getCipherSuite()); } } public class Main { public static void main(String[] args) throws Exception { SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); SSLSocket socket = (SSLSocket) factory.createSocket("127.0.0.1", 8080); String[] suites = socket.getSupportedCipherSuites(); socket.setEnabledCipherSuites(suites); socket.addHandshakeCompletedListener(new MyHandshakeListener()); socket.startHandshake(); System.out.println("Just connected to " + socket.getRemoteSocketAddress()); } }