Sample code for 30+ languages & platforms
DataFlex

Convert Certificate from DER to PEM.

See more Certificates Examples

Loads a digital certificate from any format, such as DER, and saves to PEM format.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoCert
    String sTemp1

    Move False To iSuccess

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

    // LoadFromFile will load virtually any certificate format file.
    // It will auto-recognize the format and load appropiately.
    // In this case, load a DER format certificate and convert to PEM.
    Get ComLoadFromFile Of hoCert "qa_data/certs/testCert.cer" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComExportCertPemFile Of hoCert "qa_data/certs/testCert.pem" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Converted certificate from DER to PEM format."


End_Procedure