PowerBuilder
PowerBuilder
Get the S/MIME Signer's Certificate
See more MIME Examples
Demonstrates the Chilkat Mime.LastSignerCert method, which loads the signer certificate at a zero-based index from the most recent successful verification (or security-unwrapping) into a Cert. The first argument is the signer index and the second is the receiving 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: Verifying tells you the signature is mathematically valid, but you usually also need to know who signed — the subject, the issuer, the validity dates — to decide whether to trust it. This retrieves each signer's certificate after verification so your code can inspect and apply its own trust rules. A message can have multiple signers, so iterate from
0 to NumSignerCerts - 1.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
integer n
oleobject loo_Cert
integer i
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
// After a successful verification, load each signer's certificate to inspect it. The 1st argument
// is the zero-based signer index and the 2nd is a Cert object that receives the certificate.
li_Success = loo_Mime.Verify()
if li_Success <> 1 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
n = loo_Mime.NumSignerCerts
loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")
for i = 0 to n - 1
li_Success = loo_Mime.LastSignerCert(i,loo_Cert)
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
destroy loo_Cert
return
end if
Write-Debug "Signer " + string(i) + ": " + loo_Cert.SubjectCN + " (issued by " + loo_Cert.IssuerCN + ")"
next
destroy loo_Mime
destroy loo_Cert