DataFlex
DataFlex
Use an XML Certificate Vault with IMAP
See more IMAP Examples
Demonstrates the Chilkat Imap.UseCertVault method, which associates an XmlCertVault with the Imap object as a source of certificates and private keys for S/MIME operations. The only argument is the vault. Only one vault is associated at a time.
Note: The certificate path is relative to the application's current working directory. Supply the path to your own certificate file.
Background: An
XmlCertVault is a portable container that can hold multiple certificates and keys in a single (optionally password-protected) XML file. It is a convenient way to ship the exact set of credentials an application needs without depending on the operating system's certificate stores. Associating a vault makes all of its contents available for S/MIME decryption and signature verification.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
String sPfxPassword
Variant vVault
Handle hoVault
String sTemp1
Move False To iSuccess
// Demonstrates the Imap.UseCertVault method, which associates an XmlCertVault with the Imap
// object as a source of certificates and private keys for S/MIME operations. The only
// argument is the XmlCertVault.
Get Create (RefClass(cComChilkatImap)) To hoImap
If (Not(IsComObjectCreated(hoImap))) Begin
Send CreateComObject of hoImap
End
Set ComSsl Of hoImap To True
Set ComPort Of hoImap To 993
Get ComConnect Of hoImap "imap.example.com" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComLogin Of hoImap "user@example.com" "myPassword" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// The PFX password is not hard-coded in source. Insert code here to obtain it from an
// interactive prompt, environment variable, or a secrets vault.
// Build a certificate vault and add a PFX to it.
Get Create (RefClass(cComChilkatXmlCertVault)) To hoVault
If (Not(IsComObjectCreated(hoVault))) Begin
Send CreateComObject of hoVault
End
Get ComAddPfxFile Of hoVault "qa_data/smime.pfx" sPfxPassword To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoVault To sTemp1
Showln sTemp1
Procedure_Return
End
// Associate the vault with the Imap object. Only one vault is associated at a time.
Get pvComObject of hoVault to vVault
Get ComUseCertVault Of hoImap vVault To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComDisconnect Of hoImap To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure