?
Solved

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

Posted on 2004-04-15
5
Medium Priority
?
2,825 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 180 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

777 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