PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
oleobject loo_Cert
li_Success = 0
loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
destroy loo_Mime
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Mime.LoadMimeFile("qa_data/signed.eml")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// 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.
loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")
li_Success = loo_Cert.LoadFromFile("qa_data/signer.cer")
if li_Success = 0 then
Write-Debug loo_Cert.LastErrorText
destroy loo_Mime
destroy loo_Cert
return
end if
li_Success = loo_Mime.SetVerifyCert(loo_Cert)
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
destroy loo_Cert
return
end if
// Now verify using the supplied certificate.
li_Success = loo_Mime.Verify()
if li_Success <> 1 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
destroy loo_Cert
return
end if
Write-Debug "Signature verified using the supplied certificate."
destroy loo_Mime
destroy loo_Cert