Sample code for 30+ languages & platforms
PowerBuilder

Example: Crypt2.LastSignerCert method

Demonstrates how to call the LastSignerCert method.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Crypt
string ls_P7m_path
string ls_Out_path
integer li_NumSigners
integer i
oleobject loo_Cert

li_Success = 0

loo_Crypt = create oleobject
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2")
if li_rc < 0 then
    destroy loo_Crypt
    MessageBox("Error","Connecting to COM object failed")
    return
end if

ls_P7m_path = "qa_data/p7m/Firma.docx.p7m"
ls_Out_path = "qa_output/Firma.docx"

li_Success = loo_Crypt.VerifyP7M(ls_P7m_path,ls_Out_path)
if li_Success = 0 then
    Write-Debug loo_Crypt.LastErrorText
    destroy loo_Crypt
    return
end if

// Examine the certificate(s) used for signing.
li_NumSigners = loo_Crypt.NumSignerCerts
i = 0

loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")

do while i < li_NumSigners
    loo_Crypt.LastSignerCert(i,loo_Cert)
    Write-Debug "Signer: " + loo_Cert.SubjectDN
    i = i + 1
loop


destroy loo_Crypt
destroy loo_Cert