Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.security.NoSuchProviderException: no such provider: SUN

I have implemented two factor authentication with QR code. I've done it using GoogleAuth library. In my local environment works like a charm but when I deploy the application on WebSphere 8.5.5 it throws this error:

java.security.NoSuchProviderException: no such provider: SUN

And GoogleAuth throw this exception:

Could not initialise SecureRandom with the specified provider: SUN. 
Another provider can be chosen setting the com.warrenstrange.googleauth.rng.algorithmProvider system property

on this method:

private String getRandomNumberAlgorithm()
{
    return System.getProperty(RNG_ALGORITHM, DEFAULT_RANDOM_NUMBER_ALGORITHM);
}

I found this issue on project's GitHub page that is very similar to my problem and here the guy who wrote this library explaines what this method does:

The library currently gets a SecureRandom instance using the SecureRandom#getInstance method and specifying the SHA1PRNG algorithm and the SUN provider

I understood that I have to override SUN provider with another one using System.setProperty("com.warrenstrange.googleauth.rng.algorithmProvider", "property"), because the system can't find it, but I don't understand why is throwing the exception. On my machine I run the application with Java 7 and Websphere uses the same version. The difference is the application that runs on WebSphere is compiled with Java 6.

My questions are:

Why is throwing this exception? Isn't SUN provider part of Java?

What other provider should I use and how?

like image 984
amicoderozer Avatar asked Dec 02 '25 23:12

amicoderozer


1 Answers

The difference is that SUN provider is not available by default in some WebSphere/Java versions. You can check, if it is present in the java.security file in WebSphere/AppServer/java/jre/lib/security directory.

Specify IBMJCE as provider via that property to use it instead of SUN

like image 120
Gas Avatar answered Dec 05 '25 11:12

Gas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!