?
Solved

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

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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