Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) Examine KeyInfo Certificate in XML Signature

This example loads signed XML and gets the signing certificate, assuming the certificate is contained in X509Certificate within the KeyInfo.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoDsig
    Variant vSbXml
    Handle hoSbXml
    Boolean iSuccess
    Variant vXmlKeyInfo
    Handle hoXmlKeyInfo
    String sCertBase64
    Handle hoCert
    String sTemp1
    Boolean bTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatXmlDSig)) To hoDsig
    If (Not(IsComObjectCreated(hoDsig))) Begin
        Send CreateComObject of hoDsig
    End
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbXml
    If (Not(IsComObjectCreated(hoSbXml))) Begin
        Send CreateComObject of hoSbXml
    End

    Get ComLoadFile Of hoSbXml "c:/aaworkarea/elias/3/face_f09006808443a699d1b.xml" "utf-8" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Failed to load XML file."
        Procedure_Return
    End

    Get pvComObject of hoSbXml to vSbXml
    Get ComLoadSignatureSb Of hoDsig vSbXml To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoDsig To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Get the KeyInfo XML.
    Get ComGetKeyInfo Of hoDsig To vXmlKeyInfo
    If (IsComObject(vXmlKeyInfo)) Begin
        Get Create (RefClass(cComChilkatXml)) To hoXmlKeyInfo
        Set pvComObject Of hoXmlKeyInfo To vXmlKeyInfo
    End
    Get ComLastMethodSuccess Of hoDsig To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoDsig To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComGetXml Of hoXmlKeyInfo To sTemp1
    Showln sTemp1
    Showln "----"

    // 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>
    Get ComGetChildContent Of hoXmlKeyInfo "*:X509Data|*:X509Certificate" To sCertBase64
    Get ComLastMethodSuccess Of hoXmlKeyInfo To bTemp1
    If (bTemp1 <> True) Begin
        Showln "No X509Certificate found in the KeyInfo."
        Procedure_Return
    End

    // Load a certificate object w/ the base64.
    Get Create (RefClass(cComChilkatCert)) To hoCert
    If (Not(IsComObjectCreated(hoCert))) Begin
        Send CreateComObject of hoCert
    End
    Get ComLoadFromBase64 Of hoCert sCertBase64 To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Examine the cert..
    Get ComSubjectDN Of hoCert To sTemp1
    Showln "SubjectDN: " sTemp1
    Get ComIssuerDN Of hoCert To sTemp1
    Showln "IssuerDN: " sTemp1
    Get ComSerialDecimal Of hoCert To sTemp1
    Showln "SerialNumber as Decimal: " sTemp1

    Send Destroy of hoXmlKeyInfo


End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.