AutoIt Requires Chilkat v11.0.0+
AutoIt
Verify a signed message with a trusted public key file
See more DKIM Examples
Use the saved signed message and its matching public PEM file to test a signing configuration before publishing DNS. This verifier caches the key for the exact selector and domain. A different pair can trigger normal DNS lookup, so the example also checks which signature actually verified.
Load the key from a trusted source independent of the received message. A pass with a locally supplied key confirms the cryptographic match. Use the published-key check to test what recipients can retrieve.
Chilkat AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$oMessage = ObjCreate("Chilkat.BinData")
$bSuccess = $oMessage.LoadFile("signed.eml")
If ($bSuccess <> True) Then
ConsoleWrite("Could not read signed.eml." & @CRLF)
Exit
EndIf
$oVerifier = ObjCreate("Chilkat.Dkim")
Local $sDomain = "example.com"
Local $selector = "mail2026"
$bSuccess = $oVerifier.LoadPublicKeyFile($selector,$sDomain,"dkim-public.pem")
If ($bSuccess <> True) Then
ConsoleWrite($oVerifier.LastErrorText & @CRLF)
Exit
EndIf
; signed.eml from the signing example has our newly added signature at index zero.
If ($oVerifier.NumDkimSigs($oMessage) = 0) Then
ConsoleWrite("No DKIM signature in signed.eml." & @CRLF)
Exit
EndIf
$bSuccess = $oVerifier.DkimVerify(0,$oMessage)
If ($bSuccess <> True) Then
ConsoleWrite($oVerifier.LastErrorText & @CRLF)
ConsoleWrite($oVerifier.VerifyInfo & @CRLF)
Exit
EndIf
$oInfo = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oInfo.Load($oVerifier.VerifyInfo)
If (($bSuccess <> True) Or ($oInfo.StringOfEquals("domain",$sDomain,True) <> True) Or ($oInfo.StringOfEquals("selector",$selector,True) <> True)) Then
ConsoleWrite("The first signature is not from the selected domain and selector." & @CRLF)
Exit
EndIf
ConsoleWrite("Signature verified with the saved key for " & $selector & "._domainkey." & $sDomain & @CRLF)