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
(Tcl) 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.
load ./chilkat.dll # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set dsig [new_CkXmlDSig] set sbXml [new_CkStringBuilder] set success [CkStringBuilder_LoadFile $sbXml "c:/aaworkarea/elias/3/face_f09006808443a699d1b.xml" "utf-8"] if {$success != 1} then { puts "Failed to load XML file." delete_CkXmlDSig $dsig delete_CkStringBuilder $sbXml exit } set success [CkXmlDSig_LoadSignatureSb $dsig $sbXml] if {$success != 1} then { puts [CkXmlDSig_lastErrorText $dsig] delete_CkXmlDSig $dsig delete_CkStringBuilder $sbXml exit } # Get the KeyInfo XML. # xmlKeyInfo is a CkXml set xmlKeyInfo [CkXmlDSig_GetKeyInfo $dsig] if {[CkXmlDSig_get_LastMethodSuccess $dsig] != 1} then { puts [CkXmlDSig_lastErrorText $dsig] delete_CkXmlDSig $dsig delete_CkStringBuilder $sbXml exit } puts [CkXml_getXml $xmlKeyInfo] puts "----" # 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> set certBase64 [CkXml_getChildContent $xmlKeyInfo "*:X509Data|*:X509Certificate"] if {[CkXml_get_LastMethodSuccess $xmlKeyInfo] != 1} then { puts "No X509Certificate found in the KeyInfo." delete_CkXmlDSig $dsig delete_CkStringBuilder $sbXml exit } # Load a certificate object w/ the base64. set cert [new_CkCert] set success [CkCert_LoadFromBase64 $cert $certBase64] if {$success != 1} then { puts [CkCert_lastErrorText $cert] delete_CkXmlDSig $dsig delete_CkStringBuilder $sbXml delete_CkCert $cert exit } # Examine the cert.. puts "SubjectDN: [CkCert_subjectDN $cert]" puts "IssuerDN: [CkCert_issuerDN $cert]" puts "SerialNumber as Decimal: [CkCert_serialDecimal $cert]" delete_CkXml $xmlKeyInfo delete_CkXmlDSig $dsig delete_CkStringBuilder $sbXml delete_CkCert $cert |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.