java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/OAEPPADDING

Got below error during web service request:-

java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/OAEPPADDING
at javax.crypto.Cipher.getInstance(DashoA12275)
at org.apache.ws.security.util.WSSecurityUtil.getCipherInstance(WSSecurityUtil.java:703)
at org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:145)
at org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:114)

This appears to BouncyCastle is missing from class path.  Or Bouncycastle jar may still in the classpath – but it’s not picked as a crypto provider.

Try below solution:

Download the Bouncycastle jar corresponding to your JDK from here and copy it to [JAVA_HOME]\jre\lib\ext\

Set following in [JAVA_HOME]\jre\lib\security\java.security under;

#
# List of providers and their preference orders (see above):
#
security.provider.X=org.bouncycastle.jce.provider.BouncyCastleProviderOR

In code add Bouncycastle as a provider.

import java.security.Security;  
import org.bouncycastle.jce.provider.BouncyCastleProvider;  
 
Security.addProvider(new BouncyCastleProvider());

Leave a Reply

Your email address will not be published. Required fields are marked *