Archived Forum Post

Index of archived forum posts

Question:

Prevent Email.SetFromMimeObject from auto decrypting an encrypted Mime object

Nov 18 '12 at 14:22

Hi,

This is our code flow of a function: Plain Email => Convert to Mime => Sign with Mime.AddDetachedSignature => Encrypt with Mime.AddEncryptCert and Mime.EncryptN => Convert back to Email => Send out using MailMan.

The reason we don't use Encrypt and Sign functions of Email is we need to manipulate the Mime object during signing and encryption since Email doesn't have AddDetachedSignature and Encrypt/EncryptN functions.

When we use the function Email.SetFromMimeObject, it automatically unwraps security of the Mime object. Is there any way we can convert from a Mime object to Email object without unencrypt it automatically?


Answer

Unfortunately, it's not possible. The solution is to change the workflow to this: Plain Email => Add From/To/Subject/etc. => Convert to Mime => Sign with Mime.AddDetachedSignature => Encrypt with Mime.AddEncryptCert and Mime.EncryptN => => Send out using MailMan.SendMime

(When an email object loads MIME via the LoadEml method, or by calling SetFromMimeText, or when it is loaded internally by the MailMan/IMAP objects when receiving email from a server, the MIME is decomposed and stored in an internal email object model. Because the MIME is decomposed, it is at this point that all signatures (if present) must be verified because the MIME is no longer available in its original form. Therefore, it is not possible to unwrap the security layers at a later time. The results of signature verification and/or decryption are available in the email object properties: ReceivedSigned, ReceivedEncrypted, SignaturesValid, Decrypted, and by methods: GetSignedByCert, GetEncryptedByCert, etc.Note: This only applies to the Chilkat.Email object, not the Chilkat.Mime object.)