DataFlex
DataFlex
Provide a Certificate Vault to MailMan
See more POP3 Examples
Demonstrates the Chilkat MailMan.UseCertVault method, which provides an XML certificate vault to be searched for certificates and private keys when MailMan performs operations such as encryption, decryption, signing, or signature verification. This example builds a vault from a PFX, attaches it, and fetches a message that Chilkat can decrypt using the vault.
Background: A certificate vault is a portable, in-memory store of certificates and private keys. Rather than wiring up a specific certificate for each operation, you load your credentials into one
XmlCertVault and hand it to MailMan, which then searches it automatically whenever a key is needed. This is especially useful on platforms without an OS certificate store, or when one application handles several identities.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
Variant vVault
Handle hoVault
Variant vEmail
Handle hoEmail
String sTemp1
Boolean bTemp1
Move False To iSuccess
// Demonstrates the MailMan.UseCertVault method, which provides an XML certificate vault to
// be searched for certificates and private keys when MailMan performs operations such as
// encryption, decryption, signing, or signature verification.
Get Create (RefClass(cComChilkatMailMan)) To hoMailman
If (Not(IsComObjectCreated(hoMailman))) Begin
Send CreateComObject of hoMailman
End
// Configure the POP3 server connection.
Set ComMailHost Of hoMailman To "pop.example.com"
Set ComMailPort Of hoMailman To 995
Set ComPopSsl Of hoMailman To True
Set ComPopUsername Of hoMailman To "user@example.com"
Set ComPopPassword Of hoMailman To "myPassword"
// Build a certificate vault from a PFX (certificate + private key).
Get Create (RefClass(cComChilkatXmlCertVault)) To hoVault
If (Not(IsComObjectCreated(hoVault))) Begin
Send CreateComObject of hoVault
End
Get ComAddPfxFile Of hoVault "qa_data/certs/certs.pfx" "pfx_password" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoVault To sTemp1
Showln sTemp1
Procedure_Return
End
// Make the vault available to MailMan for crypto operations.
Get pvComObject of hoVault to vVault
Get ComUseCertVault Of hoMailman vVault To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
// Fetch a message; Chilkat draws on the vault if a private key is needed to decrypt it.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Get pvComObject of hoEmail to vEmail
Get ComFetchOne Of hoMailman False 0 1 vEmail To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComDecrypted Of hoEmail To bTemp1
Showln "Decrypted = " bTemp1
// Note: The path "qa_data/certs/certs.pfx" is a relative local filesystem path,
// relative to the current working directory of the running application.
// Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
// connects and authenticates -- using the property settings above -- whenever a server
// operation requires it. Calling the explicit connect/authenticate methods can still be
// helpful to determine whether a failure occurs while connecting or while authenticating.
End_Procedure