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

04-09 1481阅读

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.(BaseAsymmetric.java:54)
	at cn.hutool.crypto.asymmetric.AbstractAsymmetricCrypto.(AbstractAsymmetricCrypto.java:39)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.(AsymmetricCrypto.java:155)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.(AsymmetricCrypto.java:137)
	at cn.hutool.crypto.asymmetric.AsymmetricCrypto.(AsymmetricCrypto.java:86)
	at cn.hutool.crypto.asymmetric.RSA.(RSA.java:87)
	at com.bocloud.devops.utils.RSAUtil.(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()
	at com.bocloud.devops.encrypt.config.RSAConfig$$EnhancerBySpringCGLIB$$93b07a93$$FastClassBySpringCGLIB$$dce9d6e8.invoke()
	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()
	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目录下

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

目前我的java版本是1.8.0_391

如果不行,需要修改Java\jdk-1.8\jre\lib\security目录下java.security文件

添加security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider

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

VPS购买请点击我

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

目录[+]