SunJSSE Provider Class Test

Q

How to test SunJSSE Provider Classes?

✍: FYIcenter.com

A

SunJSSE Provider Classes are hidden in some library files in JDK 9 and newer releases. They were stored in jsse.jar JDK 8 and older releases.

The following sample program, SunJsseClassTest.java, shows you how to test SunJSSE Provider Classes:

// Copyright (c) FYIcenter.com
import java.net.*;
import java.io.*;
import javax.net.ssl.*;

public class SunJsseClassTest {
  public static void main(String[] args) throws Exception {
    System.out.println("JSSE provider name specified in ssl.ServerSocketFactory.provider:");
    String provider = System.getProperty("ssl.ServerSocketFactory.provider");
    System.out.println("   "+provider);

    System.out.println("Class names of default JSSE provider:");
    SSLServerSocketFactory factory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    SSLServerSocket socket = (SSLServerSocket)factory.createServerSocket(1443);
    System.out.println("   "+factory.getClass().getName());
    System.out.println("   "+socket.getClass().getName());
    socket.close();

    System.out.println("Class names of SunJSSE provider:");
    SSLContext context = SSLContext.getInstance("SSL", "SunJSSE");
    context.init(null, null, null);
    factory = context.getServerSocketFactory();
    socket = (SSLServerSocket)factory.createServerSocket(1443);
    System.out.println("   "+factory.getClass().getName());
    System.out.println("   "+socket.getClass().getName());
    socket.close();
  }
}

Run the above program, you will see:

fyicenter> java SunJsseClassTest.java

JSSE provider name specified in ssl.ServerSocketFactory.provider:
   null

Class names of default JSSE provider:
   sun.security.ssl.SSLServerSocketFactoryImpl
   sun.security.ssl.SSLServerSocketImpl

Class names of SunJSSE provider:
   sun.security.ssl.SSLServerSocketFactoryImpl
   sun.security.ssl.SSLServerSocketImpl

The output confirms that SunJSSE classes are available. And they are used as the default provider for SSL protocol.

 

Downloading jsse.jar (JDK 8) Java Secure Socket Extension

Where jsse.jar in JDK

Downloading jsse.jar - Java Secure Socket Extension

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

2023-01-23, 378🔥, 1💬