B4X Requires Chilkat v11.8.0+
B4X
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 B4X Downloads
Dim success As Boolean = False
Dim pfx As ChilkatPfx
pfx.Initialize
' 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 ChilkatCert
caCert.Initialize("caCert")
success = caCert.LoadFromFile("qa_data/intermediate_ca.cer")
If success = False Then
Log(caCert.LastErrorText)
Return
End If
Dim pem As ChilkatPem
pem.Initialize
success = pem.AddCert(caCert, False)
If success = False Then
Log(pem.LastErrorText)
Return
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 = False Then
Log(pfx.LastErrorText)
Return
End If
Log("The certificates of the PEM object were added as a chain-building source.")