Register the SunJSSE Provider

You need to explicitly register the SunJSSE provider before accessing its services. This registration can be done in two possible ways: static or dynamic.

Static Registration

Edit the security property file. for WIN32, this file is as follows:

<java-home>\lib\security\java.security

For any Unix-based system ( Solaris, Linux and so on), this file is as follows:

<java-home>/lib/security/java.security

The java.security file contains one property of the type: security.provider.n=providerClassName

This property declares a provider and sets its preference order (n). If no specific provider is requested, the preference order determines the order in which providers will be searched. Set this property as follows:

security.provider.1=com.sun.net.ssl.internal.ssl.Provider security.provider.2=sun.security.provider.Sun

SunJSSE will now be the first preferred provider.

Dynamic Registration

Programmatically, dynamic registration is done by adding the following line of code to the program seeking to use JSSE services:

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

This line of code should be added to a program before using JSSE, preferably in the application or servlet's initialization method.The provider is now added dynamically at runtime using the java.net.Security class.

Readers should note that when the provider is set statically, it is available to any JSSE program on the system. On the other hand, if the property is not set statically, every program using JSSE classes will have to essentially include code to configure the provider.

0 0

Post a comment

  • Receive news updates via email from this site