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
(AutoIt) 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.
; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oDsig = ObjCreate("Chilkat.XmlDSig") $oSbXml = ObjCreate("Chilkat.StringBuilder") Local $bSuccess = $oSbXml.LoadFile("c:/aaworkarea/elias/3/face_f09006808443a699d1b.xml","utf-8") If ($bSuccess <> True) Then ConsoleWrite("Failed to load XML file." & @CRLF) Exit EndIf $bSuccess = $oDsig.LoadSignatureSb($oSbXml) If ($bSuccess <> True) Then ConsoleWrite($oDsig.LastErrorText & @CRLF) Exit EndIf ; Get the KeyInfo XML. Local $oXmlKeyInfo = $oDsig.GetKeyInfo() If ($oDsig.LastMethodSuccess <> True) Then ConsoleWrite($oDsig.LastErrorText & @CRLF) Exit EndIf ConsoleWrite($oXmlKeyInfo.GetXml() & @CRLF) ConsoleWrite("----" & @CRLF) ; 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> Local $sCertBase64 = $oXmlKeyInfo.GetChildContent("*:X509Data|*:X509Certificate") If ($oXmlKeyInfo.LastMethodSuccess <> True) Then ConsoleWrite("No X509Certificate found in the KeyInfo." & @CRLF) Exit EndIf ; Load a certificate object w/ the base64. $oCert = ObjCreate("Chilkat.Cert") $bSuccess = $oCert.LoadFromBase64($sCertBase64) If ($bSuccess <> True) Then ConsoleWrite($oCert.LastErrorText & @CRLF) Exit EndIf ; Examine the cert.. ConsoleWrite("SubjectDN: " & $oCert.SubjectDN & @CRLF) ConsoleWrite("IssuerDN: " & $oCert.IssuerDN & @CRLF) ConsoleWrite("SerialNumber as Decimal: " & $oCert.SerialDecimal & @CRLF) |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.