Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Pfx
oleobject loo_Vault

li_Success = 0

loo_Pfx = create oleobject
li_rc = loo_Pfx.ConnectToNewObject("Chilkat.Pfx")
if li_rc < 0 then
    destroy loo_Pfx
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  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.
loo_Vault = create oleobject
li_rc = loo_Vault.ConnectToNewObject("Chilkat.XmlCertVault")

li_Success = loo_Vault.AddCertFile("qa_data/intermediate_ca.cer")
if li_Success = 0 then
    Write-Debug loo_Vault.LastErrorText
    destroy loo_Pfx
    destroy loo_Vault
    return
end if

//  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.
li_Success = loo_Pfx.UseCertVault(loo_Vault)
if li_Success = 0 then
    Write-Debug loo_Pfx.LastErrorText
    destroy loo_Pfx
    destroy loo_Vault
    return
end if

Write-Debug "Certificate vault registered as a chain-building source."


destroy loo_Pfx
destroy loo_Vault