Method 1:
1. Modify the following two files
%JDK_Home%\jre\lib\security\java.security
%JRE_Home%\jre\lib\security\java.security
Append the last line
security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=sun.security.ec.SunEC
security.provider.4=com.sun.net.ssl.internal.ssl.Provider
security.provider.5=com.sun.crypto.provider.SunJCE
security.provider.6=sun.security.jgss.SunProvider
security.provider.7=com.sun.security.sasl.Provider
security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI
security.provider.9=sun.security.smartcardio.SunPCSC
security.provider.10=sun.security.mscapi.SunMSCAPI
security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider
2. Put bcprov-ext-jdk16-143.jar into
%JDK_Home%\jre\lib\ext
%JRE_Home%\jre\lib\ext
Method 2:
1. Introduce the bcprov-ext-jdk16-1.46.jar package in the project
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk16</artifactId>
<version>1.46</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
2. Add a static block to the encryption class.
static{
try{
Security.addProvider(newBouncyCastleProvider());
}catch(Exceptione){
e.printStackTrace();
}
}
Similar Posts:
- [Solved] Java.security.nosuchalgorithmexception: cannot find any provider supporting, mainmethod for AES encryption error
- [Solved] IDEA springboot Startup Error: SLF4J:Failed to load class “org.slf4j.impl.StaticLoggerBinder”
- Springboot startup error start bean ‘eurekaautoserviceregistration’ NullPointerException
- [Solved] javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair
- [Solved] SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
- [Solved] SparkSQL Error: org.apache.hadoop.security.HadoopKerberosName.setRuleMechanism
- Springboot always reports an error when importing JSP dependencies
- Maven does not have a servlet (an error is reported after the servlet is created)
- Unregistering JMX-exposed beans on shutdown Solution
- [Solved] Encryption and decryption error: java.lang.SecurityException: JCE cannot authenticate the provider BC