Hi,

I work with Jakarta-tomcat and I have JCE(java cryptography package) 1.2.1 into 
context\webinfo\lib extension 
I am using JDK 1.3 andI have followed all installation issues required and granted all 
permissions needed but it just won't work with Tomcat.

The same piece of code works well executed from java command line, Forte, netbeans or 
weblogic but not using tomcat.

This is the error message:

PoolTcpConnector: Starting Ajp12ConnectionHandler on 8007 
java.lang.ExceptionInInitializerError: java.lang.SecurityException: Cannot set up 
certs for trusted CAs at javax.crypto.b.<clinit>([DashoPro-V1.2-120198]) at 
javax.crypto.Cipher.getInstance([DashoPro-V1.2-120198])

Decrypter class:

import java.io.*;
import java.util.*;
import javax.crypto.*;
import java.security.*;
import javax.crypto.spec.*;
import java.security.spec.*;
import com.portland.adx.Header;
import com.sun.crypto.provider.SunJCE;


public class Decryption {
    
    private Cryptography c;
       
    public Decryption() {
       c = new Cryptography();
    }
    
     public Header decryptHeader(Object tmp){
        
        Cipher desCipher = null;
        Header header = null;
        
        try {
                  
            desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
            desCipher.init(Cipher.DECRYPT_MODE, c.desKey);
            
            SealedObject toDecrypt = (SealedObject)tmp;
            header = (Header) toDecrypt.getObject(desCipher);
      
            }catch(Exception e) {
            
                System.err.println(e.toString());
                return null;
        }
        
        return header;
    }    
    
}//end class



and Cryptography class:


import java.io.*;
import java.util.*;
import sun.security.*;
import javax.crypto.*;
import java.security.*;
import javax.crypto.spec.*;
import java.security.spec.*;
import sun.security.provider.*;
import com.sun.crypto.provider.SunJCE;

public class Cryptography {

  SecretKeySpec desKey;
  byte[] keyBuffer;

  public Cryptography() {

   try {
       
    // Add SunJCE to the list of providers
    SunJCE jce = new SunJCE();
    Security.addProvider(jce);
    
    //generating secret key
    keyBuffer = "02010387".getBytes();
    desKey = new SecretKeySpec(keyBuffer,"DES");
    
    }catch(Exception e){
     
        e.printStackTrace();
        
    }
 
  }
 
}


Any help would be very much apreciated

Regards
Frustated

Reply via email to