aspose file tools*
The moose likes Security and the fly likes how to solve exception java.lang.SecurityException: JCE cannot authenticate the provider BC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "how to solve exception java.lang.SecurityException: JCE cannot authenticate the provider BC" Watch "how to solve exception java.lang.SecurityException: JCE cannot authenticate the provider BC" New topic
Author

how to solve exception java.lang.SecurityException: JCE cannot authenticate the provider BC

Shah Jenish
Greenhorn

Joined: Feb 19, 2009
Posts: 13
Hello All,

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 Eclipse.

But when I made executable jar for my application which internally has 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
at javax.crypto.Cipher.getInstance(DashoA13*..)

Can anybody please guide me how can I solve this problem?

Thanks in Advance,
Jenish
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
But when I made executable jar for my application which internally has BouncyCastle jar

Does this mean that you un-jar'ed the BC jar, and then added the resulting classes to your jar file? If so, that will remove the digital signature that's present in the BC jar file. You need to keep that file intact.
Shah Jenish
Greenhorn

Joined: Feb 19, 2009
Posts: 13
Nope I did not un-jared anything..

I am using Eclipse IDE. I added BC jar in my class path of the Eclipse Project because my class uses BC jar classes.

Now when I create runnable jar in eclipse, it automatically un-jared BC jar and add classes in executable jar.

Can you please suggest a way to keep application and BC jar separate?

Thanks in Advance,
Jenish
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
You'd need to distribute the BC jar separately from your application jar. Not sure how that would be done in Eclipse, but I'm sure it can be set not to include the BC classes in the final application jar.
greg stark
Ranch Hand

Joined: Aug 10, 2006
Posts: 220
You realize that cross-posting the same question in multiple forums is considered anti-social?


Nice to meet you.
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Please help, I am facing the same issue, I am using Maven 2.0 to build my application jar and I put the bouncy castle jars in my project dependencies, while making the final jar, the bouncy castle jars get extracted and they loose the signatures... (I assume this is what happens)

becaue I get the same error.... while decryption....

JCE cannot authenticate the provider BC
javax.crypto.Cipher.getInstance(DashoA12275),
org.bouncycastle.openpgp.PGPSecretKey.extractKeyData(Unknown Source), org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey(........

I use this code to see if BC gets installed and it does->



Output




Please help how do I pact the signed jar into my application jar without extracting the bouncy castle jars. : (
Thanks a lot in advance... !


Time is what we want the most, but what we use the worst. -- William Penn
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
Why can't you just ship several jar files? That's how many (most?) applications work.
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Okay, will try that and one more question, if I change the name of the signed jar to a different name than which it is published in the website, will it affect the signature / authentication ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
if I change the name of the signed jar to a different name than which it is published in the website, will it affect the signature / authentication ?

That's easy enough to test, but I don't think it will affect it - the signature is about the file contents, not its name.
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

yup, everything's working fine if I ship the jars separately from my application jars and yes changing the name doesn't matter, thanks : ).
Tarun Khandelwal
Greenhorn

Joined: Feb 23, 2012
Posts: 19
Hello All,

I am having the same Problem.
I tried shipping jar externally but then i am getting NoClassDefFound Error for SunJCE_b class.
Can you please tell me how can i ship the jar successfully.

Thanks,
Tarun Khandelwal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to solve exception java.lang.SecurityException: JCE cannot authenticate the provider BC