Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) Get Certificates within XML SignatureDemonstrates how to get the certificates contained within an XML signature.
; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oSbXml = ObjCreate("Chilkat.StringBuilder") ; Load XML containing one or more signatures. Local $bSuccess = $oSbXml.LoadFile("qa_data/xml_dsig_valid_samples/multipleSigners/sp.pdf.XAdES.xml","utf-8") If ($bSuccess = False) Then ConsoleWrite("Failed to load the XML file.." & @CRLF) Exit EndIf $oDsig = ObjCreate("Chilkat.XmlDSig") ; First load the XML containing the signatures to be verified. ; Note that this particular Signature already contains the RSA public key that will be used ; for verification. $bSuccess = $oDsig.LoadSignatureSb($oSbXml) If ($bSuccess <> True) Then ConsoleWrite($oDsig.LastErrorText & @CRLF) Exit EndIf ; For each signature, verify and also get the certificate(s) contained within each Signature. Local $i = 0 $oSaCerts = ObjCreate("Chilkat.StringArray") $oCert = ObjCreate("Chilkat.Cert") ConsoleWrite("numSignatures = " & $oDsig.NumSignatures & @CRLF) While $i < $oDsig.NumSignatures ; Select the Nth signature by setting the Selector property. $oDsig.Selector = $i Local $bVerifyReferenceDigests = True Local $bVerified = $oDsig.VerifySignature($bVerifyReferenceDigests) ConsoleWrite("Signature " & ($i + 1) & " verified = " & $bVerified & @CRLF) ; Get the certificates embedded in this signature. $oSaCerts.Clear $bSuccess = $oDsig.GetCerts($oSaCerts) If ($bSuccess = True) Then Local $iJ = 0 While $iJ < $oSaCerts.Count $bSuccess = $oCert.LoadFromBase64($oSaCerts.GetString($iJ)) If ($bSuccess = True) Then ConsoleWrite(" " & $oCert.SubjectDN & @CRLF) EndIf $iJ = $iJ + 1 Wend EndIf $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.