5

I have developed an application in which I have used the Cryptography with the help of BountyCastle.jar. I also had a line Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

Everything works fine when I execute the program from Netbeans

But when I packaging the application in an executable jar which internally uses BouncyCastle jar and execute the jar,

I am getting exception

JCE cannot authenticate the provider BC java.lang.SecurityException: JCE cannot authenticate the provider BC

Is there any other approch to implement the same. Because it is difficult for non technical person to add BountyCastle.jar in ext folder of jre. so is there any other method to solve my problem.

Is there any method to exclude BountyCastle.jar while packaging jar in netbeans so that will accessible from external lib folder.

NULL Pointer
  • 129
  • 1
  • 1
  • 10
  • Just checking: have you asked on the BC mailing list? They take this kind of question all the time. You could probably find the answer there, then come back and post it here for others to find. – CBHacking Sep 25 '15 at 06:14
  • @CBHacking thanks for reply. but i am not aware of BC mailing list. can you please share a link for same. it will easy for me to post my query – NULL Pointer Sep 25 '15 at 06:29
  • 1
    The page for the BC Java mailing lists is http://bouncycastle.org/mailing_lists.html. It has subscription instructions and a searchable archive. You want the `dev-crypto` list. – CBHacking Sep 25 '15 at 06:36
  • Possible duplicate of [JCE cannot authenticate the provider BC in java swing application](https://stackoverflow.com/questions/13721579/jce-cannot-authenticate-the-provider-bc-in-java-swing-application) – Vadzim Oct 03 '17 at 20:18

2 Answers2

3

The BouncyCastle jar archive is signed by BouncyCastle to prevent unauthorized changes. It needs the JCA signature in order to be trusted as a cryptography provider, so do not remove it.

See a related post

Community
  • 1
  • 1
Axel Kemper
  • 10,544
  • 2
  • 31
  • 54
1

Don't add the class to your fat/assembly jar created by mvn/sbt. Make it provided. Download the jars from the official web page and add the jar separately to classpath of your program.

Dragonborn
  • 1,755
  • 1
  • 16
  • 37