DataFlex
DataFlex
Remove All S/MIME Security Layers (UnwrapSecurity)
See more MIME Examples
Demonstrates the Chilkat Mime.UnwrapSecurity method, which removes supported S/MIME security layers and restores the underlying MIME content. It takes no arguments and handles both layer orders: signed-then-encrypted and encrypted-then-signed.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: A message can be both signed and encrypted, in either order, producing nested S/MIME wrappers.
UnwrapSecurity peels them all off in one call — verifying signatures and decrypting as it goes — so you do not have to detect the layering and call Verify and Decrypt in the right sequence yourself. Decryption still requires the recipient's certificate and private key to be configured.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMime
String sTemp1
Move False To iSuccess
// Demonstrates the Mime.UnwrapSecurity method, which removes supported S/MIME security layers and
// restores the underlying MIME content. It takes no arguments and handles both layer orders
// (signed-then-encrypted and encrypted-then-signed).
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get ComLoadMimeFile Of hoMime "qa_data/secured.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// A single call peels off the signature and/or encryption layers. (Decryption requires the
// appropriate certificate/private key to be configured first.)
Get ComUnwrapSecurity Of hoMime To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComContentType Of hoMime To sTemp1
Showln "Security layers removed. Content-Type is now: " sTemp1
End_Procedure