Tcl
Tcl
Supply a Fallback Certificate for S/MIME Verification
See more MIME Examples
Demonstrates the Chilkat Mime.SetVerifyCert method, which supplies a signer-certificate fallback for subsequent signature verification. The only argument is the Cert.
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: Most signed messages embed the signer's certificate, so
Verify can find it automatically. But some signatures omit it to save space, expecting the recipient to already have it. This method provides that certificate as a fallback so verification can proceed — the S/MIME equivalent of already knowing the sender's public key out of band.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
set mime [new_CkMime]
set success [CkMime_LoadMimeFile $mime "qa_data/signed.eml"]
if {$success == 0} then {
puts [CkMime_lastErrorText $mime]
delete_CkMime $mime
exit
}
# Supply a signer-certificate fallback for verification. This is useful when the signature does
# not embed the signer certificate and Chilkat cannot otherwise locate it.
set cert [new_CkCert]
set success [CkCert_LoadFromFile $cert "qa_data/signer.cer"]
if {$success == 0} then {
puts [CkCert_lastErrorText $cert]
delete_CkMime $mime
delete_CkCert $cert
exit
}
set success [CkMime_SetVerifyCert $mime $cert]
if {$success == 0} then {
puts [CkMime_lastErrorText $mime]
delete_CkMime $mime
delete_CkCert $cert
exit
}
# Now verify using the supplied certificate.
set success [CkMime_Verify $mime]
if {$success != 1} then {
puts [CkMime_lastErrorText $mime]
delete_CkMime $mime
delete_CkCert $cert
exit
}
puts "Signature verified using the supplied certificate."
delete_CkMime $mime
delete_CkCert $cert