- SSL Socket Information


How to get more information about the SSL Socket object? It is created as "SSLSocketFactory.createSocket()".

✍: FYIcenter


If you created a URL object with "new", you can use the following sample Java code to get more information about the URL object:

// Copyright (c)

public class SslSocketInfo {
   public static void main(String[] args) throws Exception {
      String host = "";
      SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
      SSLSocket socket = (SSLSocket)factory.createSocket(host, 443);

    System.out.println("SSL Socket Information");
      System.out.println("   Class name: "+socket.getClass().getName());
      System.out.println("   Remote address = "+socket.getInetAddress());
      System.out.println("   Remote port = "+socket.getPort());
      System.out.println("   Local socket address = "+socket.getLocalSocketAddress());
      System.out.println("   Local address = "+socket.getLocalAddress().toString());
      System.out.println("   Local port = "+socket.getLocalPort());
      System.out.println("   Need client authentication = "+socket.getNeedClientAuth());

      SSLSession session = socket.getSession();
      System.out.println("   Cipher suite = "+session.getCipherSuite());
      System.out.println("   Protocol = "+session.getProtocol());


You can compile and run the above example in a command window:


\fyicenter>\local\jdk-1.8.0\bin\java SslSocketInfo

SSL Socket Information
   Class name:
   Remote address =
   Remote port = 443
   Local socket address = /
   Local address = /
   Local port = 52840
   Need client authentication = false
   Cipher suite = TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
   Protocol = TLSv1.2

The output confirms that:

  • The implementation class of the JSSE API is actually used to support SSL Socket communication.
  • The communication data is encrypted with AES_128 cipher. - SSL Cipher List - SSL Socket Client Example

Examples for jsse.jar - Java Secure Socket Extension

⇑⇑ FAQ for jsse.jar - Java Secure Socket Extension

2018-03-31, 1761🔥, 0💬