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

 

 

 

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