Solved

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

Posted on 2004-04-15
5
2,597 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
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 90 total points
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:jackiemani
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now