Classic ASP
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
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.
set imap = Server.CreateObject("Chilkat.Imap")
imap.Ssl = 1
imap.Port = 993
success = imap.Connect("imap.example.com")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
Response.End
End If
success = imap.Login("user@example.com","myPassword")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
Response.End
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.
set vault = Server.CreateObject("Chilkat.XmlCertVault")
success = vault.AddPfxFile("qa_data/smime.pfx",pfxPassword)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( vault.LastErrorText) & "</pre>"
Response.End
End If
' Associate the vault with the Imap object. Only one vault is associated at a time.
success = imap.UseCertVault(vault)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
Response.End
End If
success = imap.Disconnect()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
Response.End
End If
%>
</body>
</html>