使用bouncycastle 报错 bcprov-jdk15on-1.64.jar has unsigned / JCE cannot authenticate the provider BC

JDK版本 1.7 

bouncycastle 包:

org.bouncycastle

bcprov-jdk15on

1.64



报错堆栈信息如下:

java.security.NoSuchProviderException: JCE cannot authenticate the provider BC

at javax.crypto.JceSecurity.getInstance(JceSecurity.java:101)

at javax.crypto.KeyGenerator.getInstance(KeyGenerator.java:265)

......

Caused by: java.util.jar.JarException: file:/C:/Users/xxxx/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.64/bcprov-jdk15on-1.64.jar has unsigned entries - org/bouncycastle/LICENSE.class

at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:462)

at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:322)

at javax.crypto.JarVerifier.verify(JarVerifier.java:250)

at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:161)

at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:187)

at javax.crypto.JceSecurity.getInstance(JceSecurity.java:98)



报错加载jar包时签名验证不通过,导致NoSuchProviderException。

如果jdk版本换成1.8就可以正常加载运行了。

官方的解释如下图:


使用bouncycastle 报错 bcprov-jdk15on-1.64.jar has unsigned / JCE cannot authenticate the provider BC_第1张图片

所以如果你不是使用jdk1.8版本的话,可以使用这个包:

org.bouncycastle

bcprov-jdk15to18

1.64

你可能感兴趣的:(使用bouncycastle 报错 bcprov-jdk15on-1.64.jar has unsigned / JCE cannot authenticate the provider BC)