Visual FoxPro Requires Chilkat v11.0.0+
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loStore
LOCAL loSearch
LOCAL loCert
LOCAL loPrivateKey
LOCAL loSigner
LOCAL loMessage
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
loStore = CreateObject('Chilkat.CertStore')
lnSuccess = loStore.OpenCurrentUserStore(1)
IF (lnSuccess <> 1) THEN
? loStore.LastErrorText
RELEASE loStore
CANCEL
ENDIF
loSearch = CreateObject('Chilkat.JsonObject')
loSearch.UpdateString("thumbprint","YOUR_CERTIFICATE_THUMBPRINT")
loCert = CreateObject('Chilkat.Cert')
lnSuccess = loStore.FindCert(loSearch,loCert)
IF (lnSuccess <> 1) THEN
? loStore.LastErrorText
RELEASE loStore
RELEASE loSearch
RELEASE loCert
CANCEL
ENDIF
IF (loCert.HasPrivateKey() <> 1) THEN
? "The selected certificate has no accessible private key."
RELEASE loStore
RELEASE loSearch
RELEASE loCert
CANCEL
ENDIF
loPrivateKey = CreateObject('Chilkat.PrivateKey')
lnSuccess = loCert.GetPrivateKey(loPrivateKey)
IF (lnSuccess <> 1) THEN
? loCert.LastErrorText
RELEASE loStore
RELEASE loSearch
RELEASE loCert
RELEASE loPrivateKey
CANCEL
ENDIF
loSigner = CreateObject('Chilkat.Dkim')
loSigner.DkimDomain = "example.com"
loSigner.DkimSelector = "mail2026"
loSigner.DkimAlg = "rsa-sha256"
lnSuccess = loSigner.SetDkimPrivateKey(loPrivateKey)
IF (lnSuccess <> 1) THEN
? loSigner.LastErrorText
RELEASE loStore
RELEASE loSearch
RELEASE loCert
RELEASE loPrivateKey
RELEASE loSigner
CANCEL
ENDIF
loMessage = CreateObject('Chilkat.BinData')
lnSuccess = loMessage.LoadFile("message.eml")
IF (lnSuccess <> 1) THEN
? "Could not read message.eml."
RELEASE loStore
RELEASE loSearch
RELEASE loCert
RELEASE loPrivateKey
RELEASE loSigner
RELEASE loMessage
CANCEL
ENDIF
lnSuccess = loSigner.DkimSign(loMessage)
IF (lnSuccess <> 1) THEN
? loSigner.LastErrorText
RELEASE loStore
RELEASE loSearch
RELEASE loCert
RELEASE loPrivateKey
RELEASE loSigner
RELEASE loMessage
CANCEL
ENDIF
lnSuccess = loMessage.WriteFile("signed.eml")
IF (lnSuccess <> 1) THEN
? "Could not write signed.eml."
RELEASE loStore
RELEASE loSearch
RELEASE loCert
RELEASE loPrivateKey
RELEASE loSigner
RELEASE loMessage
CANCEL
ENDIF
? "Saved signed.eml."
RELEASE loStore
RELEASE loSearch
RELEASE loCert
RELEASE loPrivateKey
RELEASE loSigner
RELEASE loMessage