Sample code for 30+ languages & platforms
DataFlex

Convert to DER encoded X.509 Certificate (.cer, .crt)

See more Certificates Examples

Loads a digital certificate from any format and saves to a binary DER encoded X.509 Certificate (.cer, .crt).

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 PEM format certificate and convert to DER.
    Get ComLoadFromFile Of hoCert "/Users/chilkat/testData/pem/chilkat.pem" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComExportCertDerFile Of hoCert "chilkat.der" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Converted certificate from PEM to DER format."


End_Procedure