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 Encryption
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) Load .crl, Convert to XML, Get Revoked Serial Numbers and Dates

Load a binary .crl file (Certificate Revocation List), converts to XML, and then gets the revoked certificate serial numbers and revocation dates.

Note: This example requires Chilkat v9.5.0.77 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Variant vBdCrl
    Handle hoBdCrl
    Boolean iSuccess
    Handle hoAsn
    Handle hoXml
    Integer i
    Integer iCount_i
    String sTagPath
    Integer j
    Integer iCount_j
    Integer k
    Integer iCount_k
    String sRevokedCertSerialHex
    String sDateRevoked
    Handle hoDt
    String sTemp1

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

    // Load a binary .crl file.
    Get Create (RefClass(cComChilkatBinData)) To hoBdCrl
    If (Not(IsComObjectCreated(hoBdCrl))) Begin
        Send CreateComObject of hoBdCrl
    End
    Get ComLoadFile Of hoBdCrl "qa_data/crl/ca1.crl" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Failed to load CRL file."
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatAsn)) To hoAsn
    If (Not(IsComObjectCreated(hoAsn))) Begin
        Send CreateComObject of hoAsn
    End
    Get pvComObject of hoBdCrl to vBdCrl
    Get ComLoadBd Of hoAsn vBdCrl To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoAsn To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Convert ASN.1 to XML and load into xml and re-emit for pretty printing..
    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Get ComAsnToXml Of hoAsn To sTemp1
    Get ComLoadXml Of hoXml sTemp1 To iSuccess
    Get ComSaveXml Of hoXml "qa_output/crl.xml" To iSuccess

    // Use this online tool to generate parsing code from CRL XML: 
    // Generate Parsing Code from XML

    // Here's code to parse the XML.  This code was generated by the above tool,
    // and then we modified it by removing unneeded code and changing some names

    Get Create (RefClass(cComCkDateTime)) To hoDt
    If (Not(IsComObjectCreated(hoDt))) Begin
        Send CreateComObject of hoDt
    End

    Move 0 To i
    Get ComNumChildrenHavingTag Of hoXml "sequence" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoXml To i

        Move 0 To j
        Get ComNumChildrenHavingTag Of hoXml "sequence[i]|sequence" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoXml To j

            Move 0 To k
            Get ComNumChildrenHavingTag Of hoXml "sequence[i]|sequence[j]|sequence" To iCount_k
            While (k < iCount_k)
                Set ComK Of hoXml To k

                // Get the revoked certificate's serial number in uppercase hex.
                Get ComGetChildContent Of hoXml "sequence[i]|sequence[j]|sequence[k]|int" To sRevokedCertSerialHex
                Showln "serial number: " sRevokedCertSerialHex

                // Get the date/time revoked.  It will be a string formatted as "YYMMDDhhmmssZ", such as "181023093028Z"
                Get ComGetChildContent Of hoXml "sequence[i]|sequence[j]|sequence[k]|utctime" To sDateRevoked

                // Starting in Chilkat v9.5.0.77, date/time strings formatted as YYMMDDhhmmssZ can be parsed as follows:
                Get ComSetFromTimestamp Of hoDt sDateRevoked To iSuccess
                Get ComGetAsRfc822 Of hoDt False To sTemp1
                Showln "date revoked: " sTemp1

                Move k + 1 To k
            Loop

            Move j + 1 To j
        Loop

        Move i + 1 To i
    Loop



End_Procedure

 

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