Archived Forum Post

Index of archived forum posts


Decoding Signed and Encrypted Emails

Sep 27 '17 at 20:44

I'm having an issue decoding encrypted emails that are also digitally signed. I have no problem with either signed emails or encrypted emails, both decode and allow access to the email body and attachment(s).

This is using the ActiveX Crypt2 and Mime packages, current version.

  1. For encrypted emails, I use the CkDecryptFile method, then load the decrypted smime file and use the UnwrapSecurity method followed by GetPart to extract all the mime parts.

  2. For signed emails, I use the UnwrapSecurity method followed by GetPart.

This works great for both signed and encrypted emails, but fails for signed/encrypted emails. If I follow 1) above for signed/encrypted, I end up with a smime.p7m attachment. If I try to decode that using UnwrapSecurity, I end up with a corrupted mime file, with non-ascii characters embedded.

Would appreciate any suggestions on alternate methods for doing this, or where I might be going wrong.