Sample code for 30+ languages & platforms
VBScript Requires Chilkat v11.8.0+

Add a PEM Source of Certificates for Chain Building

See more PFX/P12 Examples

Demonstrates Pfx.AddPemSource, which adds the certificates of a Pem object to the set of certificate sources available for chain building.

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 takes the certificates the Pem object has at the time of the call. Providing extra intermediate certificates lets Chilkat complete the chains of the certificates of a PFX. The added certificates are a lookup source only: they do not become part of the PFX. AddPemSource can be called multiple times. Each call adds more certificates to the ones already added. AddPemSource was added in Chilkat v11.8.0 and replaces UseCertVault.

Chilkat VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

success = 0

set pfx = CreateObject("Chilkat.Pfx")

'  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 an additional certificate (such as an intermediate CA certificate), and add it to a Pem object.
set caCert = CreateObject("Chilkat.Cert")
success = caCert.LoadFromFile("qa_data/intermediate_ca.cer")
If (success = 0) Then
    outFile.WriteLine(caCert.LastErrorText)
    WScript.Quit
End If

set pem = CreateObject("Chilkat.Pem")
success = pem.AddCert(caCert,0)
If (success = 0) Then
    outFile.WriteLine(pem.LastErrorText)
    WScript.Quit
End If

'  Make the certificates of the Pem object available as sources for chain building.  The call takes
'  the certificates the Pem object has at this moment.  AddPemSource can be called multiple times.
'  Each call adds more certificates to the ones already added.
success = pfx.AddPemSource(pem)
If (success = 0) Then
    outFile.WriteLine(pfx.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine("The certificates of the PEM object were added as a chain-building source.")

outFile.Close