|  | 
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
| (Swift) 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. 
 func chilkatTest() { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. let dsig = CkoXmlDSig()! let sbXml = CkoStringBuilder()! var success: Bool = sbXml.loadFile("c:/aaworkarea/elias/3/face_f09006808443a699d1b.xml", charset: "utf-8") if success != true { print("Failed to load XML file.") return } success = dsig.loadSignatureSb(sbXml) if success != true { print("\(dsig.lastErrorText!)") return } // Get the KeyInfo XML. var xmlKeyInfo: CkoXml? = dsig.getKeyInfo() if dsig.lastMethodSuccess != true { print("\(dsig.lastErrorText!)") return } print("\(xmlKeyInfo!.getXml()!)") print("----") // 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> var certBase64: String? = xmlKeyInfo!.getChildContent("*:X509Data|*:X509Certificate") if xmlKeyInfo!.lastMethodSuccess != true { print("No X509Certificate found in the KeyInfo.") return } // Load a certificate object w/ the base64. let cert = CkoCert()! success = cert.load(fromBase64: certBase64) if success != true { print("\(cert.lastErrorText!)") return } // Examine the cert.. print("SubjectDN: \(cert.subjectDN!)") print("IssuerDN: \(cert.issuerDN!)") print("SerialNumber as Decimal: \(cert.serialDecimal!)") xmlKeyInfo = nil } | ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.