Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot set up certs for trusted CAs at javax.crypto.f

843811Jul 29 2008 — edited Aug 1 2008
I've been struggling for a week or two to get anything in the javax.crypto package to work for me.

Environment:
J2SE 1.4.2, IBM Rational Application Developer 6.0, IBM WebSphere App Server 6.0.2.15 (although that last one's not really relevant for this example problem)

Any program I make that utilizes Java Cryptography gives the following exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
at javax.crypto.KeyGenerator.getInstance(Unknown Source)
at DESKeyGenerator.main(DESKeyGenerator.java:18)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.f.<clinit>(Unknown Source)
... 2 more

Most recommendations I've come across for solving this involved reordering the crytographic service providers in java.security, so here is my current arrangement:

security.provider.1=com.ibm.crypto.provider.IBMJCE
security.provider.2=com.ibm.jsse.IBMJSSEProvider
security.provider.3=com.ibm.jsse2.IBMJSSEProvider2
security.provider.4=com.ibm.security.jgss.IBMJGSSProvider
security.provider.5=com.ibm.security.cert.IBMCertPath

Finally, here's an example program that causes the exception:
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import javax.crypto.KeyGenerator;
import com.ibm.crypto.provider.IBMJCE;

public class DESKeyGenerator {

  public static void main(String[] args) {
    //Security.addProvider(new IBMJCE());

    try {
      KeyGenerator kg = KeyGenerator.getInstance("DES");
      Key key = kg.generateKey();
      System.out.println("Key format: " + key.getFormat());
      System.out.println("Key algorithm: " + key.getAlgorithm());
    }

    catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    }
  }
}
The exception's the same with the Security.addProvider line uncommented.

Any ideas or guidance would be greatly appreciated. Thanks for your time.

Edited by: jevans on Jul 29, 2008 7:22 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2008
Added on Jul 29 2008
1 comment
689 views