第一种方式
1、修改以下两个文件
%JDK_Home%\jre\lib\security\java.security
%JRE_Home%\jre\lib\security\java.security
追加 最后一行
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、将bcprov-ext-jdk16-143.jar 放到
%JDK_Home%\jre\lib\ext
%JRE_Home%\jre\lib\ext
第二种方式
1、在工程内引入bcprov-ext-jdk16-1.46.jar包
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk16</artifactId>
<version>1.46</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
2、在加密类中加入静态块。
static{
try{
Security.addProvider(new BouncyCastleProvider());
}catch(Exception e){
e.printStackTrace();
}
}
bcprov-ext-jdk16-143.jar下载路径:
链接:https://pan.baidu.com/s/1Sy0o5Uu56QhfzudFyv1gAw
提取码:vl7v