Sample code for 30+ languages & platforms
DataFlex

Get Certificate Public Key from PEM

See more Certificates Examples

Demonstrates how to load a PEM file containing a certificate and access the public key.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoCert
    Variant vPubkey
    Handle hoPubkey
    String sTemp1

    Move False To iSuccess

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

    Get ComLoadFromFile Of hoCert "qa_data/pem/my_cert.pem" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatPublicKey)) To hoPubkey
    If (Not(IsComObjectCreated(hoPubkey))) Begin
        Send CreateComObject of hoPubkey
    End
    Get pvComObject of hoPubkey to vPubkey
    Get ComGetPublicKey Of hoCert vPubkey To iSuccess

    // Examine the public key as XML..
    Get ComGetXml Of hoPubkey To sTemp1
    Showln sTemp1


End_Procedure