|  | 
Chilkat  HOME  Android™  AutoIt  C  C#  C++  Chilkat2-Python  CkPython  Classic ASP  DataFlex  Delphi DLL  Go  Java  Node.js  Objective-C  PHP Extension  Perl  PowerBuilder  PowerShell  PureBasic  Ruby  SQL Server  Swift  Tcl  Unicode C  Unicode C++  VB.NET  VBScript  Visual Basic 6.0  Visual FoxPro  Xojo Plugin
| (Delphi ActiveX) Get Certificates within XML SignatureDemonstrates how to get the certificates contained within an XML signature. 
 uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB; ... procedure TForm1.Button1Click(Sender: TObject); var sbXml: TChilkatStringBuilder; success: Integer; dsig: TChilkatXmlDSig; i: Integer; saCerts: TCkStringArray; cert: TChilkatCert; bVerifyReferenceDigests: Integer; bVerified: Integer; j: Integer; begin // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. sbXml := TChilkatStringBuilder.Create(Self); // Load XML containing one or more signatures. success := sbXml.LoadFile('qa_data/xml_dsig_valid_samples/multipleSigners/sp.pdf.XAdES.xml','utf-8'); if (success = 0) then begin Memo1.Lines.Add('Failed to load the XML file..'); Exit; end; dsig := TChilkatXmlDSig.Create(Self); // 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. success := dsig.LoadSignatureSb(sbXml.ControlInterface); if (success <> 1) then begin Memo1.Lines.Add(dsig.LastErrorText); Exit; end; // For each signature, verify and also get the certificate(s) contained within each Signature. i := 0; saCerts := TCkStringArray.Create(Self); cert := TChilkatCert.Create(Self); Memo1.Lines.Add('numSignatures = ' + IntToStr(dsig.NumSignatures)); while i < dsig.NumSignatures do begin // Select the Nth signature by setting the Selector property. dsig.Selector := i; bVerifyReferenceDigests := 1; bVerified := dsig.VerifySignature(bVerifyReferenceDigests); Memo1.Lines.Add('Signature ' + IntToStr(i + 1) + ' verified = ' + IntToStr(Ord(bVerified))); // Get the certificates embedded in this signature. saCerts.Clear(); success := dsig.GetCerts(saCerts.ControlInterface); if (success = 1) then begin j := 0; while j < saCerts.Count do begin success := cert.LoadFromBase64(saCerts.GetString(j)); if (success = 1) then begin Memo1.Lines.Add(' ' + cert.SubjectDN); end; j := j + 1; end; end; i := i + 1; end; end; | ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.