Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mail signing and encrypting with Apache Camel

I want to sign and encrypt my mail.

My current camel version is 2.13.0.

Is there a camel feature which I can use for this purpose?

Body is plain text therefore XMLDSig or so cannot be used.

Expected result should be a mail with these headers:

  • Content-Type: application/pkcs7-mime; name="smime.p7m"; smime-type=enveloped-data
  • Content-Transfer-Encoding: base64
like image 584
lahu89 Avatar asked Feb 29 '16 15:02

lahu89


1 Answers

I solved the problem for sending.

I created a new MimeMessage with all required parameters like from, recipient, subject and content (Multipart with body and attachments).

With BouncyCastle I signed and encrypted this MimeMessage.

I set the resulting MimeMessage as body and sent it with standard camel mail endpoint. All required parameters will be selected from the MimeMessage itself and not from the exchange headers.

For receiving I will use also the camel mail standard but with the parameter mapMailMessage=false that I can process the received javax.mail.Message itself without preprocessing. For decrypting I will also use BouncyCastle.

like image 194
lahu89 Avatar answered Sep 28 '22 07:09

lahu89