0

Getting the above exception with error log after registering BC provider dynamically and statically via

Security.addProvider(new BouncyCastleProvider());

However, on

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

I get the following error

 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)
BenhurCD
  • 71
  • 12
  • Possible duplicate of http://stackoverflow.com/questions/13721579/jce-cannot-authenticate-the-provider-bc-in-java-swing-application – fireandfuel Apr 27 '17 at 16:22

1 Answers1

0

I believe that any JCE provider JARs must be signed before they will be trusted by your Java runtime. It appears that the jar you have has content in it which is unsigned.

If this is content that you have added to the jar or a jar that you have made then check out this answer which tells you how to sign it: How to sign a custom JCE security provider

Mr Chow
  • 326
  • 5
  • 9