Solved

java.lang.ExceptionInInitializerError: java.lang.SecurityException: Cannot set up certs for trusted CAs

Posted on 2004-04-15
5
2,750 Views
Last Modified: 2012-06-27
Hai,
I get the above error when i access it from a client machine.

When i have the Server as localhost and cleint access from the same PC has no problem code works fine.

Settings
Weblogic 6.1
bea/jdk131/jre/ext/ i have copied all four files as bea/jdk131 is the JAVA_HOME path.

Also i have made this jar downloadable along witht the client program using JSP
<PARAM NAME="cache_archive" VALUE="
/jars/jce1_2_2.jar,/jars/local_policy.jar,/jars/sunjce_provider.jar,/jars/US_export_policy.jar">

i still get the above error What is the mistake i am doing?
Kindly help out.


Code is as follows!!

 Security.addProvider(
       new com.sun.crypto.provider.SunJCE());
      KeyGenerator kg = KeyGenerator.getInstance ("DES");
      kg.init (new SecureRandom ());
      SecretKey key = kg.generateKey ();
      SecretKeyFactory skf = SecretKeyFactory.getInstance ("DES");
      Class spec = Class.forName ("javax.crypto.spec.DESKeySpec");
      DESKeySpec ks = (DESKeySpec)skf.getKeySpec (key , spec);
      ObjectOutputStream oos = new ObjectOutputStream (new FileOutputStream ("C:/e_Communicator/Auth/keyfile"));
      oos.writeObject (ks.getKey ());

      Cipher c = Cipher.getInstance ("DES/CBC/PKCS5Padding");
      c.init (Cipher.ENCRYPT_MODE , key);
      CipherOutputStream cos = new CipherOutputStream (new FileOutputStream ("C:/e_Communicator/Auth/Authfile") , c);
      PrintWriter pw = new PrintWriter (new OutputStreamWriter (cos));
      String input = jtx_UserID.getText () + ":" + jtx_UserNM.getText () + ":" + jtx_UserKey.getText () + ":" +
                 entitySetCurDate.getValueAt ("CURR_DATE").toString ();
      System.out.println (input);
      pw.println (input);
      pw.close ();
      oos.writeObject (c.getIV ());
      oos.close ();

Rgds
Mani
0
Comment
Question by:jackiemani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 90 total points
ID: 10839429
Hi,

The JDK/JRE used by weblogic is different from the one that you use on the command line.

Check the security file (java.security) for that JDK available under \lib\security and make changes if required for the provider you are using. Also check the classpath used by Weblogic. If required edit the startweblogic.cmd file to include the required files in the classpath. You can put the required files (generally jce1_2_1.jar and sunjce_provider.jar) in the \lib\ext of the jdk used by weblogic.


Here are the details I found:

1. Go to $JAVA_HOME/jre/lib/security directory
2. You should find the file java.security
3. Edit the file to add the following line to the list of providers:

security.provider.3=com.sun.crypto.provider.SunJCE

The new list looks like this:

#
# List of providers and their preference orders (see above):
#
security.provider.1=sun.security.provider.Sun
security.provider.2=com.sun.rsajca.Provider
security.provider.3=com.sun.crypto.provider.SunJCE

This adds the provider SunJCE to the list of providers.

4. Copy the following files to jre/lib/ext directory:

US_export_policy.jar
jce1_2_1.jar
sunjce_provider.jar
local_policy.jar

That should work like a charm.
0
 

Author Comment

by:jackiemani
ID: 10839441
Hi Tried all the things above before posting but doesnt work still.
Security modified,Policy modified files copied and also have set class path in weblogic. yet client gets the error!
While using jre1.3.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 10839457
0
 

Author Comment

by:jackiemani
ID: 10846998
Hi i found the problem is cause the client doesnt have the copy of the 4 jar files in the jre installed folder that is java.home/lib/ext in the client side when i copied the 4 jars in the client and tested it worked.

how do it set the server so that these jars are automatically copied to the client machine? I have done the above setting explained by Sudhakar.

0
 

Author Comment

by:jackiemani
ID: 10847072
And closely following and doing the settings i do not get the error
"java.lang.ExceptionInInitializerError: java.lang.SecurityException: Cannot set up certs for trusted CAs"

But i get
java.lang.NoClassDefFoundError
      at javax.crypto.KeyGenerator.getInstance(DashoA6275)




0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question