Exception :JCE cannot authenticate the provider BC

Hi all,

I tried to encrypt some data using BC,when I load the privatekey and password ,an exception was throwed:

Exception in thread "main" java.io.IOException: error constructing MAC: java.sec

urity.NoSuchProviderException: JCE cannot authenticate the provider BC

at org.bouncycastle.jce.provider.JDKPKCS12KeyStore.engineLoad(JDKPKCS12K

eyStore.java:715)

at java.security.KeyStore.load(KeyStore.java:1150)

at com.paypal.crypto.sample.ShowProviders.main(ShowProviders.java:32)

the code throwed exception:

27Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

28String keyPass="lk404161";

29String prvKey="my-prvkey.p12";

30CertificateFactory cf = CertificateFactory.getInstance("X509", "BC");

31KeyStore ks = KeyStore.getInstance("PKCS12", "BC");

32ks.load( new FileInputStream(prvKey), keyPass.toCharArray() );

I don't know what caused this exception,my JCE is 1.4.2,and BC is 1.24,the privatekey file my-prvkey.p12 is generated by OpenSSL,any body help me ?

Thanks in advance !

[1112 byte] By [LiuChanga] at [2007-11-27 9:42:35]
# 1
Have you by any chance extracted the class files from the BC provider jar?
sabre150a at 2007-7-12 23:46:19 > top of Java-index,Security,Cryptography...
# 2

Thanks,I have considented of that situation,so I downloaded a new crypto-124.zip package to replace the old one,but the exception throwed all the same.My JDK edition is 1.5.07,and I have replaced all the jar files in %JAVA_HOME%\jre\lib\security\ with JCE 1.4.2 ,I really cannot find out the reason.

LiuChanga at 2007-7-12 23:46:19 > top of Java-index,Security,Cryptography...
# 3

> My

> JDK edition is 1.5.07,and I have replaced all the jar

> files in %JAVA_HOME%\jre\lib\security\ with JCE

> 1.4.2 ,I really cannot find out the reason.

Why the heck have you done this! This has to be the cause of your problem. It is almost never wise to 'pick and mix' jars from different jdk distributions. Just stick to 1.5.07 OR 1.4.2 .

sabre150a at 2007-7-12 23:46:19 > top of Java-index,Security,Cryptography...