Solved

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

Posted on 2004-04-15
5
2,715 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
javap bin 2 40
Java Restore security prompts not working 10 50
Why doesn't this text field show up on my Applet frame? 2 19
Java basic valueOf question 1 29
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

789 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