DataFlex
DataFlex
Add a Recipient Certificate for S/MIME Encryption
See more MIME Examples
Demonstrates AddEncryptCert, which adds one recipient certificate to the list used by EncryptN. Call it once for each intended recipient, then call EncryptN to encrypt for all of them.
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. AddEncryptCert builds up the recipient list used by EncryptN. Only the public key of each certificate is required for encryption.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMime
Variant vCert
Handle hoCert
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get ComSetBodyFromPlainText Of hoMime "This message will be encrypted." To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// AddEncryptCert adds one recipient certificate to the list used by EncryptN. Call it once per
// recipient.
Get Create (RefClass(cComChilkatCert)) To hoCert
If (Not(IsComObjectCreated(hoCert))) Begin
Send CreateComObject of hoCert
End
Get ComLoadFromFile Of hoCert "qa_data/recipient.cer" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCert To sTemp1
Showln sTemp1
Procedure_Return
End
Get pvComObject of hoCert to vCert
Get ComAddEncryptCert Of hoMime vCert To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// EncryptN then encrypts for all certificates added.
Get ComEncryptN Of hoMime To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Encrypted for the added recipient(s)."
End_Procedure