Sample code for 30+ languages & platforms
Visual Basic 6.0 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 Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

Dim pfx As New ChilkatPfx

'  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.
Dim caCert As New ChilkatCert
success = caCert.LoadFromFile("qa_data/intermediate_ca.cer")
If (success = 0) Then
    Debug.Print caCert.LastErrorText
    Exit Sub
End If

Dim pem As New ChilkatPem
success = pem.AddCert(caCert,0)
If (success = 0) Then
    Debug.Print pem.LastErrorText
    Exit Sub
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
    Debug.Print pfx.LastErrorText
    Exit Sub
End If

Debug.Print "The certificates of the PEM object were added as a chain-building source."