码迷,mamicode.com
首页 > 其他好文 > 详细

JCE cannot authenticate the provider BC

时间:2019-08-28 22:43:32      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:unsigned   can   not   方法   sdn   bsp   log   错误   链接   

本文链接:https://blog.csdn.net/qq_15068711/article/details/54691934
今天使用bcprov-jdk15on.jar包时,报以下错误:

java.lang.SecurityException: JCE cannot authenticate the provider BC
at javax.crypto.Cipher.getInstance(Cipher.java:642)
at com.kadi.chekong.util.RSAUtils.encrypt(RSAUtils.java:269)
at com.kadi.chekong.util.RSAUtils.encryptString(RSAUtils.java:326)
at com.kadi.chekong.util.RSAUtilsTest.decryptAndEncrypt(RSAUtilsTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.util.jar.JarException: file:/C:/Users/Administrator/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.55/bcprov-jdk15on-1.55.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.Cipher.getInstance(Cipher.java:638)
... 26 more

在网上找了各种方法,也没解决问题。主要使用了一下方法:

1. 说maven会解压包导致jar包的签名不能使用,所以放在jre/lib/ext目录下,并使用Security.addProvider(new BouncyCastleProvider())添加Provider;

2. 怀疑LICENSE.class类有问题,所以下载源码,将main()方法去除,重新打包,还是不行,将LICENSE.java去掉,重新打包,又报另一个类has unsigned entries,无法解析整个包的文件,但又不知问题在哪;

3. 在maven仓库下载时,有察觉到1.54版本下载量较多,本人之前使用的是1.55,怀着侥幸的心里,改成1.54版本,结果运行成功,没有报以上错误。

JCE cannot authenticate the provider BC

标签:unsigned   can   not   方法   sdn   bsp   log   错误   链接   

原文地址:https://www.cnblogs.com/renjiaqi/p/11426768.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!