Sample code for 30+ languages & platforms
DataFlex

Use a Certificate Vault for Chain Building

See more PFX/P12 Examples

Demonstrates Pfx.UseCertVault, which adds the certificates in an XmlCertVault to the set of sources available for later chain-building operations such as AddCert.

The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.

Background. The call captures a point-in-time snapshot of the vault's certificates. Providing extra intermediate certificates lets Chilkat complete certificate chains when building a PFX.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoPfx
    Variant vVault
    Handle hoVault
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatPfx)) To hoPfx
    If (Not(IsComObjectCreated(hoPfx))) Begin
        Send CreateComObject of hoPfx
    End

    //  The file path is relative to the application's current working directory.  An absolute path
    //  may also be used.  Supply the path appropriate to your own environment.
    //  Load additional certificates (such as intermediate CA certificates) into a certificate vault.
    Get Create (RefClass(cComChilkatXmlCertVault)) To hoVault
    If (Not(IsComObjectCreated(hoVault))) Begin
        Send CreateComObject of hoVault
    End
    Get ComAddCertFile Of hoVault "qa_data/intermediate_ca.cer" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoVault To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Make the vault's certificates available as sources for later chain-building operations, such as
    //  AddCert.  The call captures a point-in-time snapshot of the vault's certificates.
    Get pvComObject of hoVault to vVault
    Get ComUseCertVault Of hoPfx vVault To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoPfx To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Certificate vault registered as a chain-building source."


End_Procedure