[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bouncycastle-crypto-dev
Subject:    AW: [dev-crypto] Problems using BC for encrypted Mails in Tomcat5
From:       "Celik, Servet (ext MA)" <extern.servet.celik () zivit ! de>
Date:       2008-10-21 9:32:05
Message-ID: 2AD906E80953DC11858D005056811E2B01A9466F () kmc14 ! bff ! iv ! bfinv ! de
[Download RAW message or body]

Hi!

Sorry, I didn't get you! Which 3rd party API do you mean?
All I make use of is BC.

############# Code-Snippet
message.addRecipients(Message.RecipientType.TO, to);
message.setSubject(SUBJECT);
message.setText(text, "UTF-8");
message.saveChanges();
			
String certPath = WebProperties.getProperty("empfaengerPubKeyPath");
// get the S/MIME EncryptionUtilities
EncryptionUtils smimeUtils =
EncryptionManager.getEncryptionUtils(EncryptionManager.SMIME);

// load the S/MIME keystore from the given file.
char[] smimePw = new String("TestPassWd").toCharArray();
EncryptionKeyManager smimeKeyMgr = smimeUtils.createKeyManager();
smimeKeyMgr.loadPublicKeystore(new FileInputStream(new
File(certPath+"/Test.p12")), smimePw);
			
// get the S/MIME public key for encryption
Key smimeKey = smimeKeyMgr.getPublicKey("TestKey");
			
// encrypt the message
MimeMessage smimeEncryptedMsg = smimeUtils.encryptMessage(session, message,
smimeKey);

mailQueue.add(message);
Transport.send(message);
mailQueue.remove(message);

############# End-Snippet

As I told before. This class works fine, when started as standalone
Java-Application, but does not, when put into the webapp and deployed in
Tomcat.

Using encryption for mails sent out of a sevlet container must be done
before, doesn't it? :)
I would really apreciate, when you describe me the way you solved this
common task.

Cheers,
  Servet



> -----Ursprüngliche Nachricht-----
> Von: Harakiri [mailto:harakiri_23@yahoo.com] 
> Gesendet: Donnerstag, 16. Oktober 2008 19:20
> An: 'dev-crypto@bouncycastle.org';
> Betreff: Re: [dev-crypto] Problems using BC for encrypted 
> Mails in Tomcat5.5
> 
> 
> I think that project is outdatet, BC already has an API to 
> create smime messages using java mail api - no need for 
> another 3rd party api.
> 
> Besides, adding the BC provider doesnt need to involve 
> changing a file - just do Security.addProvider(new 
> BouncyCastleProvider())
> 
> 
> --- On Thu, 10/16/08, Celik, Servet wrote:
> 
> > From: Servet Celik
> > Subject: [dev-crypto] Problems using BC for encrypted Mails in 
> > Tomcat5.5
> > To: "'dev-crypto@bouncycastle.org'" <dev-crypto@bouncycastle.org>
> > Date: Thursday, October 16, 2008, 11:52 AM
> > Hi *,
> > 
> > I try to encrypt outgoing mails from my webapplication with S/MIME 
> > using BC.
> > 
> > 
> > Therefore I make use of the BouncyCastleProvider and
> > created an example
> > according to http://javamail-crypto.sourceforge.net/.
> > Afterwards I
> > introduced Bouncycaste as securityprovider by adding the
> > line 
> > 
> "security.provider.7=org.bouncycastle.jce.provider.BouncyCastleProvide
> > r"
> > to
> > the file 
> > JAVA_HOME/jre/lib/security/java.security.
> > 
> > When I start the class as a standalone JavaApplication everything 
> > works fine, but putting it into my webapplication and calling it
> > raises an
> > Exception.
> > (DEBUG: setDebug: JavaMail version 1.4.1
> > error loading provider info: 
> > java.lang.NullPointerException
> > java.lang.NullPointerException at
> > 
> net.suberic.crypto.EncryptionManager.loadProviders(EncryptionM
> anager.java:48
> > ) at
> > 
> net.suberic.crypto.EncryptionManager.<clinit>(EncryptionManage
> r.java:37)...)
> > .
> > 
> > Here is a list of libraries, that I include in the lib-directory of 
> > the created WAR-file:
> >  - activation.jar
> >  - bcmail-jdk15-141.jar
> >  - bcprov-ext-jdk15-141.jar
> >  - javamail-crypto_060622.jar
> >  - javamail-crypto-bouncycastle-smime_060622.jar
> >  - mail.jar
> >  - mailapi.jar
> >  - smtp.jar
> > 
> > Env.:
> > Server = Tomcat 5.5
> > OS = WinXP
> > java = jdk1.5.0.14
> > 
> > I also deleted the following libs out of the WAR file's
> > lib dir and put them
> > into
> > $CATALINA-HOME$/common/endorsed. 
> >  - bcmail-jdk15-141.jar
> >  - bcprov-ext-jdk15-141.jar
> >  - javamail-crypto_060622.jar
> >  - javamail-crypto-bouncycastle-smime_060622.jar
> > 
> > But no use. I'm clueless ....
> > 
> > Thanks in advance for your effort. Any help will be apreciated.
> > 
> > Cheers,
> >   Servet
> 
> 
>       
> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic