Sample code for 30+ languages & platforms
Tcl

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

Tcl

load ./chilkat.dll

set success 0

set pfx [new_CkPfx]

#  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.
set vault [new_CkXmlCertVault]

set success [CkXmlCertVault_AddCertFile $vault "qa_data/intermediate_ca.cer"]
if {$success == 0} then {
    puts [CkXmlCertVault_lastErrorText $vault]
    delete_CkPfx $pfx
    delete_CkXmlCertVault $vault
    exit
}

#  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.
set success [CkPfx_UseCertVault $pfx $vault]
if {$success == 0} then {
    puts [CkPfx_lastErrorText $pfx]
    delete_CkPfx $pfx
    delete_CkXmlCertVault $vault
    exit
}

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

delete_CkPfx $pfx
delete_CkXmlCertVault $vault