jQuery in Action, 3rd edition
The moose likes Web Services and the fly likes Could not start up the CDSA libraries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Could not start up the CDSA libraries" Watch "Could not start up the CDSA libraries" New topic

Could not start up the CDSA libraries

arvinder khosla

Joined: Sep 04, 2009
Posts: 3
Hi All

I am using HmacSHA1 for Calculating RFC2104 compliant - base 64 encoded certificate for a given string and shared secret.
While starting the application sometimes I receive the error pasted below:

Caused by: java.lang.InternalError: Could not start up the CDSA libraries.
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1723)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at com.apple.crypto.provider.HmacCore.<clinit>(HmacCore.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at java.security.Provider$Service.newInstance(Provider.java:1130)
at javax.crypto.Mac.a(DashoA12275)
at javax.crypto.Mac.init(DashoA12275)

OS: Mac OS X Server 10.5.6

Java Details : Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237)
Java HotSpot(TM) Server VM (build 1.5.0_13-119, mixed mode)

Any clues would be helpful.

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
If you care to post some code, I could give it a try - just the part that is supposed to start up the library in question.
Best wishes!
arvinder khosla

Joined: Sep 04, 2009
Posts: 3
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

Code snippet
try {
SecretKeySpec signingKey = new SecretKeySpec(iSharedSecret.getBytes(), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
byte[] rawHmac = mac.doFinal(iValue.getBytes());
byte[] aReturnBytes = org.apache.commons.codec.binary.Base64.encodeBase64(rawHmac);
iReturnValue = new String(aReturnBytes, "utf-8") ;
} catch (Exception anException) {
_logger.error("Exception Occured while generating HMAC" , anException);
throw new Exception("Failed to generate HMAC : " + anException.getMessage());
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
Things work fine here with the following JVM:
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03-206)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-82, mixed mode)
Os: OS X 10.5.8

Have you tried to use a more recent JVM?
Best wishes!
arvinder khosla

Joined: Sep 04, 2009
Posts: 3
Thanks. For me too it works 2 out of 3 the times. Could it be jar clash. (because both com.sun.crypto.provider.*; & com.apple.crypto.provider.* provide implementations of HmacSHA1)
I was not adding the any of the imports earlier (i.e. neither of com.apple.crypto.provider.*; or com.apple.crypto.provider.*) .
Haven't seen the issue since this change.
Will check for a day or 2 and update this forum on whethr it's fixed or not.

Don't get me started about those stupid light bulbs.
subject: Could not start up the CDSA libraries
It's not a secret anymore!