• JCE cannot authenticate the provider BC


    本文链接: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版本,结果运行成功,没有报以上错误。

  • 相关阅读:
    每日博客
    每日博客之十一月读书笔记1
    每日博客
    今日收获
    今日收获
    今日收获
    动手动脑10.21
    今日收获
    今日收获
    8月21日
  • 原文地址:https://www.cnblogs.com/renjiaqi/p/11426768.html
Copyright © 2020-2023  润新知