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
(PureBasic) 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.
IncludeFile "CkCert.pb" IncludeFile "CkXml.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkXmlDSig.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. dsig.i = CkXmlDSig::ckCreate() If dsig.i = 0 Debug "Failed to create object." ProcedureReturn EndIf sbXml.i = CkStringBuilder::ckCreate() If sbXml.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkStringBuilder::ckLoadFile(sbXml,"c:/aaworkarea/elias/3/face_f09006808443a699d1b.xml","utf-8") If success <> 1 Debug "Failed to load XML file." CkXmlDSig::ckDispose(dsig) CkStringBuilder::ckDispose(sbXml) ProcedureReturn EndIf success = CkXmlDSig::ckLoadSignatureSb(dsig,sbXml) If success <> 1 Debug CkXmlDSig::ckLastErrorText(dsig) CkXmlDSig::ckDispose(dsig) CkStringBuilder::ckDispose(sbXml) ProcedureReturn EndIf ; Get the KeyInfo XML. xmlKeyInfo.i = CkXmlDSig::ckGetKeyInfo(dsig) If CkXmlDSig::ckLastMethodSuccess(dsig) <> 1 Debug CkXmlDSig::ckLastErrorText(dsig) CkXmlDSig::ckDispose(dsig) CkStringBuilder::ckDispose(sbXml) ProcedureReturn EndIf Debug CkXml::ckGetXml(xmlKeyInfo) Debug "----" ; 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> certBase64.s = CkXml::ckGetChildContent(xmlKeyInfo,"*:X509Data|*:X509Certificate") If CkXml::ckLastMethodSuccess(xmlKeyInfo) <> 1 Debug "No X509Certificate found in the KeyInfo." CkXmlDSig::ckDispose(dsig) CkStringBuilder::ckDispose(sbXml) ProcedureReturn EndIf ; Load a certificate object w/ the base64. cert.i = CkCert::ckCreate() If cert.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkCert::ckLoadFromBase64(cert,certBase64) If success <> 1 Debug CkCert::ckLastErrorText(cert) CkXmlDSig::ckDispose(dsig) CkStringBuilder::ckDispose(sbXml) CkCert::ckDispose(cert) ProcedureReturn EndIf ; Examine the cert.. Debug "SubjectDN: " + CkCert::ckSubjectDN(cert) Debug "IssuerDN: " + CkCert::ckIssuerDN(cert) Debug "SerialNumber as Decimal: " + CkCert::ckSerialDecimal(cert) CkXml::ckDispose(xmlKeyInfo) CkXmlDSig::ckDispose(dsig) CkStringBuilder::ckDispose(sbXml) CkCert::ckDispose(cert) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.