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
(DataFlex) Examine KeyInfo Certificate in XML SignatureThis example loads signed XML and gets the signing certificate, assuming the certificate is contained in X509Certificate within the KeyInfo.
Use ChilkatAx-win32.pkg Procedure Test Handle hoDsig Variant vSbXml Handle hoSbXml Boolean iSuccess Variant vXmlKeyInfo Handle hoXmlKeyInfo String sCertBase64 Handle hoCert String sTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatXmlDSig)) To hoDsig If (Not(IsComObjectCreated(hoDsig))) Begin Send CreateComObject of hoDsig End Get Create (RefClass(cComChilkatStringBuilder)) To hoSbXml If (Not(IsComObjectCreated(hoSbXml))) Begin Send CreateComObject of hoSbXml End Get ComLoadFile Of hoSbXml "c:/aaworkarea/elias/3/face_f09006808443a699d1b.xml" "utf-8" To iSuccess If (iSuccess <> True) Begin Showln "Failed to load XML file." Procedure_Return End Get pvComObject of hoSbXml to vSbXml Get ComLoadSignatureSb Of hoDsig vSbXml To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoDsig To sTemp1 Showln sTemp1 Procedure_Return End // Get the KeyInfo XML. Get ComGetKeyInfo Of hoDsig To vXmlKeyInfo If (IsComObject(vXmlKeyInfo)) Begin Get Create (RefClass(cComChilkatXml)) To hoXmlKeyInfo Set pvComObject Of hoXmlKeyInfo To vXmlKeyInfo End Get ComLastMethodSuccess Of hoDsig To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoDsig To sTemp1 Showln sTemp1 Procedure_Return End Get ComGetXml Of hoXmlKeyInfo To sTemp1 Showln sTemp1 Showln "----" // Assuming the X509Certificate is in the KeyInfo, it will look like this: // <ds:KeyInfo Id="..."> // <ds:KeyValue> // ... // <ds:X509Data> // <ds:X509Certificate>MIIHAz...</ds:X509Certificate> // </ds:X509Data> // </ds:KeyInfo> Get ComGetChildContent Of hoXmlKeyInfo "*:X509Data|*:X509Certificate" To sCertBase64 Get ComLastMethodSuccess Of hoXmlKeyInfo To bTemp1 If (bTemp1 <> True) Begin Showln "No X509Certificate found in the KeyInfo." Procedure_Return End // Load a certificate object w/ the base64. Get Create (RefClass(cComChilkatCert)) To hoCert If (Not(IsComObjectCreated(hoCert))) Begin Send CreateComObject of hoCert End Get ComLoadFromBase64 Of hoCert sCertBase64 To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoCert To sTemp1 Showln sTemp1 Procedure_Return End // Examine the cert.. Get ComSubjectDN Of hoCert To sTemp1 Showln "SubjectDN: " sTemp1 Get ComIssuerDN Of hoCert To sTemp1 Showln "IssuerDN: " sTemp1 Get ComSerialDecimal Of hoCert To sTemp1 Showln "SerialNumber as Decimal: " sTemp1 Send Destroy of hoXmlKeyInfo End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.