java.lang.SecurityException:JCE无法验证提供程序BC

时间:2017-04-20 04:49:41

标签: java-8 tomcat7 bouncycastle

通过

动态和静态地注册BC提供程序后,通过错误日志获取上述异常
Security.addProvider(new BouncyCastleProvider());

但是,

Cipher.getInstance("AES/CTS/NoPadding", "BC")

我收到以下错误

 Failure to decrypt: bad encryption: 
 java.lang.SecurityException: JCE cannot authenticate the provider BC
 Caused by: java.util.jar.JarException: 
 file:/space/uploads/unittest/jars/myjar.jar has unsigned entries - <some-location>/README.txt
 at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:500)
 at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:361)
 at javax.crypto.JarVerifier.verify(JarVerifier.java:289)
 at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:159)
 at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:185)
 at javax.crypto.Cipher.getInstance(Cipher.java:653)
 at javax.crypto.Cipher.getInstance(Cipher.java:596)

1 个答案:

答案 0 :(得分:0)

我相信任何JCE提供程序JAR必须先签名才能被Java运行时信任。看来你所拥有的jar中有无内容的内容。

如果这是您添加到jar或您制作的jar中的内容,请查看此答案,告诉您如何签名:How to sign a custom JCE security provider