PowerBuilder
PowerBuilder
Verify and Unwrap PCKS7 Signed MIME
See more MIME Examples
Demonstrates calling the Verify method to verify and unwrap PKCS7 signed MIME. The MIME is restored to the original structure that it would have originally had prior to signing. The Verify method works with both detached signatures, as well as opaque/attached signatures.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
integer li_Verified
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
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
// A PKCS7 signature usually embeds both the signing
// certificate with its public key. Therefore, it is usually
// possible to verify a signature without the need to
// already have the certificate installed.
// Load the signed MIME from a file...
li_Success = loo_Mime.LoadMimeFile("signedMime.txt")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// Verify the signed MIME and restore the MIME
// to the structure/content it had prior to signing.
li_Verified = loo_Mime.Verify()
if li_Verified = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// Examine the MIME after signature verification (i.e. "unwrapping")
Write-Debug loo_Mime.GetMime()
destroy loo_Mime