JCE cannot authenticate the provider BC因jdk版本引起的加密包报错

JCRCaused by: java.util.jar.JarException: jar:file:/app/xscloud/xs-system.jar!/BOOT-INF/lib/bcprov-jdk14-138.jar!/ has unsigned entries – org/bouncycastle/LICENSE.class

Caused by: cn.hutool.crypto.CryptoException: SecurityException: JCE cannot authenticate the provider BC
	at cn.hutool.crypto.SecureUtil.createCipher(SecureUtil.java:1029)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.initCipher(AsymmetricCrypto.java:317)
	at cn.hutool.crypto.asymmetric.RSA.initCipher(RSA.java:211)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.init(AsymmetricCrypto.java:220)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.init(AsymmetricCrypto.java:34)
	at cn.hutool.crypto.asymmetric.BaseAsymmetric.<init>(BaseAsymmetric.java:54)
	at cn.hutool.crypto.asymmetric.AbstractAsymmetricCrypto.<init>(AbstractAsymmetricCrypto.java:39)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.<init>(AsymmetricCrypto.java:155)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.<init>(AsymmetricCrypto.java:137)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.<init>(AsymmetricCrypto.java:86)
	at cn.hutool.crypto.asymmetric.RSA.<init>(RSA.java:87)
	at com.bocloud.devops.utils.RSAUtil.<init>(RSAUtil.java:16)
	at com.bocloud.devops.encrypt.config.RSAConfig.rsaUtil(RSAConfig.java:25)
	at com.bocloud.devops.encrypt.config.RSAConfig$$EnhancerBySpringCGLIB$$93b07a93.CGLIB$rsaUtil$0(<generated>)
	at com.bocloud.devops.encrypt.config.RSAConfig$$EnhancerBySpringCGLIB$$93b07a93$$FastClassBySpringCGLIB$$dce9d6e8.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
	at com.bocloud.devops.encrypt.config.RSAConfig$$EnhancerBySpringCGLIB$$93b07a93.rsaUtil(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 59 common frames omittedCaused by: java.lang.SecurityException: JCE cannot authenticate the provider BC
	at javax.crypto.Cipher.getInstance(Cipher.java:662)
	at cn.hutool.crypto.SecureUtil.createCipher(SecureUtil.java:1027)
	... 81 common frames omitted
Caused by: java.util.jar.JarException: file:/D:/maven-repository/bouncycastle/bcprov-jdk14/138/bcprov-jdk14-138.jar has unsigned entries - org/bouncycastle/LICENSE.class
	at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:510)
	at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:371)
	at javax.crypto.JarVerifier.verify(JarVerifier.java:297)
	at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:164)
	at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:190)
	at javax.crypto.Cipher.getInstance(Cipher.java:658)
	... 82 common frames omitted

原因:
高版本的jdk引起的加密包报错,可以编译代码,然后找到bcprov-jdk高版本的jar包,复制到java/jdk版本号/jre/lib/ext目录下

目前我的java版本是1.8.0_391
如果不行,需要修改Java\jdk-1.8\jre\lib\security目录下java.security文件
添加security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider

版权声明:本文为博主作者:ruantiao3440原创文章,版权归属原作者,如果侵权,请联系我们删除!

原文链接:https://blog.csdn.net/ruantiao3440/article/details/134284747

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年12月29日
下一篇 2023年12月29日

相关推荐