Sample code for 30+ languages & platforms
VBScript

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 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 the PFX bytes into a BinData.
set bd = CreateObject("Chilkat.BinData")
bLoaded = bd.LoadFile("qa_data/identity.pfx")
If (bLoaded <> 1) Then
    outFile.WriteLine("Failed to load the PFX file.")
    WScript.Quit
End If

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

'  Load the PFX / PKCS#12 container from the bytes held in the BinData.
success = pfx.LoadPfxBd(bd,password)
If (success = 0) Then
    outFile.WriteLine(pfx.LastErrorText)
    WScript.Quit
End If

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

outFile.Close