Lianja
Lianja
Cache a DKIM Public Key from a File
See more DKIM / DomainKey Examples
Demonstrates the Chilkat Dkim.LoadPublicKeyFile method, which caches an RSA public key read from a local file for a specific selector and domain. The arguments are the selector, the domain, and the public-key file path. Supported formats include PEM X.509 SubjectPublicKeyInfo and PEM PKCS#1 RSA public key.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: This is the file-based form of
LoadPublicKey, convenient when the key already lives in a .pem file — a saved copy of what the domain publishes in DNS. As with the string form, the cache is keyed on the exact selector and domain, so those must match the signature being verified. Pre-loading keys this way lets a verifier work without any DNS access at all.Chilkat Lianja Downloads
llSuccess = .F.
// Demonstrates the Dkim.LoadPublicKeyFile method, which caches an RSA public key read from a
// local file for a specific selector and domain. The 1st argument is the selector, the 2nd is
// the domain, and the 3rd is the local public-key file path.
loDkim = createobject("CkDkim")
// Read the public key from a file and cache it under the exact selector and domain. Supported
// formats include PEM X.509 SubjectPublicKeyInfo and PEM PKCS#1 RSA public key.
llSuccess = loDkim.LoadPublicKeyFile("myselector","example.com","qa_data/dkim_public.pem")
if (llSuccess = .F.) then
? loDkim.LastErrorText
release loDkim
return
endif
? "Public key loaded and cached."
release loDkim