Visual FoxPro Requires Chilkat v11.0.0+
Visual FoxPro
Prepare a DKIM public key and DNS TXT record
See more DKIM Examples
Start with an RSA signing key in dkim-private.pem. This writes its public half to dkim-public.pem for local testing and prints the TXT record to enter at your DNS provider. Keep the private PEM on the signer. Use a 2048-bit or larger RSA key for a new deployment. DKIM RSA key sizes.
Use your signing domain and selector in place of example.com and mail2026. A provider that appends the zone usually wants just mail2026._domainkey as the name. If the value exceeds 255 bytes, split it into adjacent character strings within one TXT record. DNS joins those strings without adding spaces. Publish a new selector before rotating keys and keep the old record while previously signed mail is still in transit.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loPrivateKey
LOCAL loPublicKey
LOCAL lcPValue
LOCAL lcSelector
LOCAL lcDomain
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
* Supply your RSA signing key. For an encrypted PEM, get its password from your credential store.
loPrivateKey = CreateObject('Chilkat.PrivateKey')
lnSuccess = loPrivateKey.LoadAnyFormatFile("dkim-private.pem","")
IF (lnSuccess <> 1) THEN
? loPrivateKey.LastErrorText
RELEASE loPrivateKey
CANCEL
ENDIF
loPublicKey = CreateObject('Chilkat.PublicKey')
lnSuccess = loPrivateKey.ToPublicKey(loPublicKey)
IF (lnSuccess <> 1) THEN
? loPrivateKey.LastErrorText
RELEASE loPrivateKey
RELEASE loPublicKey
CANCEL
ENDIF
IF (loPublicKey.KeyType <> "rsa") THEN
? "Choose an RSA key for this rsa-sha256 example."
RELEASE loPrivateKey
RELEASE loPublicKey
CANCEL
ENDIF
* false selects SubjectPublicKeyInfo. The p= value is base64 DER, on one line.
lcPValue = loPublicKey.GetEncoded(0,"base64")
IF (lcPValue = "") THEN
? loPublicKey.LastErrorText
RELEASE loPrivateKey
RELEASE loPublicKey
CANCEL
ENDIF
lnSuccess = loPublicKey.SavePemFile(0,"dkim-public.pem")
IF (lnSuccess <> 1) THEN
? loPublicKey.LastErrorText
RELEASE loPrivateKey
RELEASE loPublicKey
CANCEL
ENDIF
lcSelector = "mail2026"
lcDomain = "example.com"
? "TXT owner: " + lcSelector + "._domainkey." + lcDomain
? "TXT value: v=DKIM1; k=rsa; p=" + lcPValue
? "Saved dkim-public.pem."
RELEASE loPrivateKey
RELEASE loPublicKey