DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoDkim
String sTemp1
Move False To iSuccess
// 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.
Get Create (RefClass(cComChilkatDkim)) To hoDkim
If (Not(IsComObjectCreated(hoDkim))) Begin
Send CreateComObject of hoDkim
End
// 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.
Get ComLoadPublicKeyFile Of hoDkim "myselector" "example.com" "qa_data/dkim_public.pem" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoDkim To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Public key loaded and cached."
End_Procedure