Lua
Lua
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 Lua Downloads
local chilkat = require("chilkat")
local mime = chilkat.Mime.new()
local success = mime:load_mime_file("qa_data/signed.eml")
if not success then
print(mime.last_error_text)
return
end
-- 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.
local cert = chilkat.Cert.new()
success = cert:load_from_file("qa_data/signer.cer")
if not success then
print(cert.last_error_text)
return
end
success = mime:set_verify_cert(cert)
if not success then
print(mime.last_error_text)
return
end
-- Now verify using the supplied certificate.
success = mime:verify()
if not success then
print(mime.last_error_text)
return
end
print("Signature verified using the supplied certificate.")