Xojo Plugin Requires Chilkat v11.0.0+
Xojo Plugin
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 Xojo Plugin Downloads
Dim success As Boolean
success = False
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim store As New Chilkat.CertStore
success = store.OpenCurrentUserStore(True)
If (success <> True) Then
System.DebugLog(store.LastErrorText)
Return
End If
Dim search As New Chilkat.JsonObject
success = search.UpdateString("thumbprint","YOUR_CERTIFICATE_THUMBPRINT")
Dim cert As New Chilkat.Cert
success = store.FindCert(search,cert)
If (success <> True) Then
System.DebugLog(store.LastErrorText)
Return
End If
If (cert.HasPrivateKey() <> True) Then
System.DebugLog("The selected certificate has no accessible private key.")
Return
End If
Dim privateKey As New Chilkat.PrivateKey
success = cert.GetPrivateKey(privateKey)
If (success <> True) Then
System.DebugLog(cert.LastErrorText)
Return
End If
Dim signer As New Chilkat.Dkim
signer.DkimDomain = "example.com"
signer.DkimSelector = "mail2026"
signer.DkimAlg = "rsa-sha256"
success = signer.SetDkimPrivateKey(privateKey)
If (success <> True) Then
System.DebugLog(signer.LastErrorText)
Return
End If
Dim message As New Chilkat.BinData
success = message.LoadFile("message.eml")
If (success <> True) Then
System.DebugLog("Could not read message.eml.")
Return
End If
success = signer.DkimSign(message)
If (success <> True) Then
System.DebugLog(signer.LastErrorText)
Return
End If
success = message.WriteFile("signed.eml")
If (success <> True) Then
System.DebugLog("Could not write signed.eml.")
Return
End If
System.DebugLog("Saved signed.eml.")