PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
string ls_PfxPassword
oleobject loo_Vault
li_Success = 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.
loo_Imap = create oleobject
li_rc = loo_Imap.ConnectToNewObject("Chilkat.Imap")
if li_rc < 0 then
destroy loo_Imap
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Imap.Ssl = 1
loo_Imap.Port = 993
li_Success = loo_Imap.Connect("imap.example.com")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
li_Success = loo_Imap.Login("user@example.com","myPassword")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// 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.
loo_Vault = create oleobject
li_rc = loo_Vault.ConnectToNewObject("Chilkat.XmlCertVault")
li_Success = loo_Vault.AddPfxFile("qa_data/smime.pfx",ls_PfxPassword)
if li_Success = 0 then
Write-Debug loo_Vault.LastErrorText
destroy loo_Imap
destroy loo_Vault
return
end if
// Associate the vault with the Imap object. Only one vault is associated at a time.
li_Success = loo_Imap.UseCertVault(loo_Vault)
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
destroy loo_Vault
return
end if
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
destroy loo_Vault
return
end if
destroy loo_Imap
destroy loo_Vault