Classic ASP Requires Chilkat v11.0.0+
Classic ASP
Sign an email with a key in the Windows Current User certificate store
See more DKIM Examples
Run on Windows as the account that owns the signing certificate. Copy its thumbprint from Current User > Personal and supply it as hexadecimal digits. The thumbprint selects a certificate. The DKIM signature itself uses RSA-SHA256.
The certificate needs an accessible, exportable RSA private key for GetPrivateKey. Publish its matching public key under the selector in DNS. DKIM recipients use that DNS key to verify the message. An X.509 chain is unnecessary for this step.
Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
set store = Server.CreateObject("Chilkat.CertStore")
success = store.OpenCurrentUserStore(1)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( store.LastErrorText) & "</pre>"
Response.End
End If
set search = Server.CreateObject("Chilkat.JsonObject")
success = search.UpdateString("thumbprint","YOUR_CERTIFICATE_THUMBPRINT")
set cert = Server.CreateObject("Chilkat.Cert")
success = store.FindCert(search,cert)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( store.LastErrorText) & "</pre>"
Response.End
End If
If (cert.HasPrivateKey() <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "The selected certificate has no accessible private key.") & "</pre>"
Response.End
End If
set privateKey = Server.CreateObject("Chilkat.PrivateKey")
success = cert.GetPrivateKey(privateKey)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>"
Response.End
End If
set signer = Server.CreateObject("Chilkat.Dkim")
signer.DkimDomain = "example.com"
signer.DkimSelector = "mail2026"
signer.DkimAlg = "rsa-sha256"
success = signer.SetDkimPrivateKey(privateKey)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( signer.LastErrorText) & "</pre>"
Response.End
End If
set message = Server.CreateObject("Chilkat.BinData")
success = message.LoadFile("message.eml")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not read message.eml.") & "</pre>"
Response.End
End If
success = signer.DkimSign(message)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( signer.LastErrorText) & "</pre>"
Response.End
End If
success = message.WriteFile("signed.eml")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not write signed.eml.") & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Saved signed.eml.") & "</pre>"
%>
</body>
</html>