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
(Visual FoxPro) Get Certificates within XML SignatureDemonstrates how to get the certificates contained within an XML signature.
LOCAL loSbXml LOCAL lnSuccess LOCAL loDsig LOCAL i LOCAL loSaCerts LOCAL loCert LOCAL lnBVerifyReferenceDigests LOCAL lnBVerified LOCAL j * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbXml = CreateObject('Chilkat.StringBuilder') * Load XML containing one or more signatures. lnSuccess = loSbXml.LoadFile("qa_data/xml_dsig_valid_samples/multipleSigners/sp.pdf.XAdES.xml","utf-8") IF (lnSuccess = 0) THEN ? "Failed to load the XML file.." RELEASE loSbXml CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.XmlDSig') loDsig = CreateObject('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. lnSuccess = loDsig.LoadSignatureSb(loSbXml) IF (lnSuccess <> 1) THEN ? loDsig.LastErrorText RELEASE loSbXml RELEASE loDsig CANCEL ENDIF * For each signature, verify and also get the certificate(s) contained within each Signature. i = 0 * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringArray') loSaCerts = CreateObject('Chilkat.StringArray') * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Cert') loCert = CreateObject('Chilkat.Cert') ? "numSignatures = " + STR(loDsig.NumSignatures) DO WHILE i < loDsig.NumSignatures * Select the Nth signature by setting the Selector property. loDsig.Selector = i lnBVerifyReferenceDigests = 1 lnBVerified = loDsig.VerifySignature(lnBVerifyReferenceDigests) ? "Signature " + STR(i + 1) + " verified = " + STR(lnBVerified) * Get the certificates embedded in this signature. loSaCerts.Clear() lnSuccess = loDsig.GetCerts(loSaCerts) IF (lnSuccess = 1) THEN j = 0 DO WHILE j < loSaCerts.Count lnSuccess = loCert.LoadFromBase64(loSaCerts.GetString(j)) IF (lnSuccess = 1) THEN ? " " + loCert.SubjectDN ENDIF j = j + 1 ENDDO ENDIF i = i + 1 ENDDO RELEASE loSbXml RELEASE loDsig RELEASE loSaCerts RELEASE loCert |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.