Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oImap
LOCAL cPfxPassword
LOCAL oVault
nSuccess := 0
// 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.
oImap := CreateObject("Chilkat.Imap")
oImap:Ssl := 1
oImap:Port := 993
nSuccess := oImap:Connect("imap.example.com")
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
nSuccess := oImap:Login("user@example.com", "myPassword")
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
// 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.
oVault := CreateObject("Chilkat.XmlCertVault")
nSuccess := oVault:AddPfxFile("qa_data/smime.pfx", cPfxPassword)
IF (nSuccess == 0)
? oVault:LastErrorText
oImap:destroy()
oVault:destroy()
RETURN
ENDIF
// Associate the vault with the Imap object. Only one vault is associated at a time.
nSuccess := oImap:UseCertVault(oVault)
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
oVault:destroy()
RETURN
ENDIF
nSuccess := oImap:Disconnect()
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
oVault:destroy()
RETURN
ENDIF
oImap:destroy()
oVault:destroy()