Sample code for 30+ languages & platforms
VB.NET

Load a PFX from BinData

See more PFX/P12 Examples

Demonstrates Pfx.LoadPfxBd, which loads a PFX / PKCS#12 container from the bytes held in a BinData object.

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. This is the in-memory equivalent of LoadPfxFile, for when the PKCS#12 data is already available as bytes rather than in a file.

Chilkat VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim pfx As New 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 the PFX bytes into a BinData.
Dim bd As New Chilkat.BinData
Dim bLoaded As Boolean = bd.LoadFile("qa_data/identity.pfx")
If (bLoaded <> True) Then
    Debug.WriteLine("Failed to load the PFX file.")
    Exit Sub
End If


'  The PFX password should come from a secure source rather than being hard-coded.
Dim password As String = "myPfxPassword"

'  Load the PFX / PKCS#12 container from the bytes held in the BinData.
success = pfx.LoadPfxBd(bd,password)
If (success = False) Then
    Debug.WriteLine(pfx.LastErrorText)
    Exit Sub
End If

Debug.WriteLine("Loaded " & pfx.NumCerts & " certificate(s).")