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) How to Parse a X.509 Certificate and Extract its Public Key

Demonstrates how to load an X.509 certificate and extract the public key. Chilkat supports many certificate encodings:

  • DER (binary) encoded certificates (.crt/.cer)
  • PEM (BASE64) encoded certificates (.pem)
  • Load Certificates Directly from Windows Certificate Stores
  • PFX/PKCS12 (.pfx/.p12)
  • Java KeyStore (.jks)
  • Cryptographic Message Syntax Standard - PKCS #7 Certificates (.P7B)

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoCert
    Boolean iSuccess
    Variant vPubKey
    Handle hoPubKey
    String sTemp1
    Boolean bTemp1

    Get Create (RefClass(cComChilkatCert)) To hoCert
    If (Not(IsComObjectCreated(hoCert))) Begin
        Send CreateComObject of hoCert
    End

    //  Load a DER (binary) encoded certificate.
    //  To load from a .pem or .p7b, or any other file format that contains
    //  just one certificate, call LoadFromFile in exactly the same way.
    //  The LoadFromFile method automatically detects the format and loads the certificate.
    Get ComLoadFromFile Of hoCert "qa_data/certs/testCert.cer" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Get the public key:
    Get ComExportPublicKey Of hoCert To vPubKey
    If (IsComObject(vPubKey)) Begin
        Get Create (RefClass(cComChilkatPublicKey)) To hoPubKey
        Set pvComObject Of hoPubKey To vPubKey
    End
    Get ComLastMethodSuccess Of hoCert To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Examine the key type.
    //  A PublicKey object can contain an RSA, ECC, or DSA public key.
    //  The KeyType property will contain "rsa", "ecc", or "dsa".
    Get ComKeyType Of hoPubKey To sTemp1
    Showln "key type = " sTemp1

    Send Destroy of hoPubKey


End_Procedure

 

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