Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
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
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(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-2019 Chilkat Software, Inc. All Rights Reserved.