DataFlex
DataFlex
Use an XmlCertVault for S/MIME Operations
See more MIME Examples
Loads a CMS/PKCS #7 encrypted S/MIME message and decrypts it back to the original MIME content.
UseCertVault sets an XmlCertVault as the single active source of certificates and private keys for S/MIME encryption, decryption, signing, and verification.
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 certificate vault is a convenient container for one or more certificates and keys. Only one vault is active at a time; assigning a new vault replaces the previous one.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMime
Variant vVault
Handle hoVault
String sPfxPassword
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get ComLoadMimeFile Of hoMime "qa_data/encrypted.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// Use an XmlCertVault as the source of certificates and private keys for S/MIME operations. The
// only argument is the vault. Only one vault is active at a time.
Get Create (RefClass(cComChilkatXmlCertVault)) To hoVault
If (Not(IsComObjectCreated(hoVault))) Begin
Send CreateComObject of hoVault
End
Move "myPfxPassword" To sPfxPassword
Get ComAddPfxFile Of hoVault "qa_data/recipient.pfx" sPfxPassword To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoVault To sTemp1
Showln sTemp1
Procedure_Return
End
Get pvComObject of hoVault to vVault
Get ComUseCertVault Of hoMime vVault To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// Decryption (and signing/verification) now draws credentials from the vault.
Get ComDecrypt Of hoMime To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Decrypted using the certificate vault."
End_Procedure