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
(PowerBuilder) 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.
integer li_rc oleobject loo_Dsig oleobject loo_SbXml integer li_Success oleobject loo_XmlKeyInfo string ls_CertBase64 oleobject loo_Cert // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Dsig = create oleobject // Use "Chilkat_9_5_0.XmlDSig" for versions of Chilkat < 10.0.0 li_rc = loo_Dsig.ConnectToNewObject("Chilkat.XmlDSig") if li_rc < 0 then destroy loo_Dsig MessageBox("Error","Connecting to COM object failed") return end if loo_SbXml = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbXml.ConnectToNewObject("Chilkat.StringBuilder") li_Success = loo_SbXml.LoadFile("c:/aaworkarea/elias/3/face_f09006808443a699d1b.xml","utf-8") if li_Success <> 1 then Write-Debug "Failed to load XML file." destroy loo_Dsig destroy loo_SbXml return end if li_Success = loo_Dsig.LoadSignatureSb(loo_SbXml) if li_Success <> 1 then Write-Debug loo_Dsig.LastErrorText destroy loo_Dsig destroy loo_SbXml return end if // Get the KeyInfo XML. loo_XmlKeyInfo = loo_Dsig.GetKeyInfo() if loo_Dsig.LastMethodSuccess <> 1 then Write-Debug loo_Dsig.LastErrorText destroy loo_Dsig destroy loo_SbXml return end if Write-Debug loo_XmlKeyInfo.GetXml() Write-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> ls_CertBase64 = loo_XmlKeyInfo.GetChildContent("*:X509Data|*:X509Certificate") if loo_XmlKeyInfo.LastMethodSuccess <> 1 then Write-Debug "No X509Certificate found in the KeyInfo." destroy loo_Dsig destroy loo_SbXml return end if // Load a certificate object w/ the base64. loo_Cert = create oleobject // Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0 li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert") li_Success = loo_Cert.LoadFromBase64(ls_CertBase64) if li_Success <> 1 then Write-Debug loo_Cert.LastErrorText destroy loo_Dsig destroy loo_SbXml destroy loo_Cert return end if // Examine the cert.. Write-Debug "SubjectDN: " + loo_Cert.SubjectDN Write-Debug "IssuerDN: " + loo_Cert.IssuerDN Write-Debug "SerialNumber as Decimal: " + loo_Cert.SerialDecimal destroy loo_XmlKeyInfo destroy loo_Dsig destroy loo_SbXml destroy loo_Cert |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.