Sample code for 30+ languages & platforms
Delphi DLL

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 Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
pfx: HCkPfx;
bd: HCkBinData;
bLoaded: Boolean;
password: PWideChar;

begin
success := False;

pfx := CkPfx_Create();

//  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.
bd := CkBinData_Create();
bLoaded := CkBinData_LoadFile(bd,'qa_data/identity.pfx');
if (bLoaded <> True) then
  begin
    Memo1.Lines.Add('Failed to load the PFX file.');
    Exit;
  end;

//  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 := CkPfx_LoadPfxBd(pfx,bd,password);
if (success = False) then
  begin
    Memo1.Lines.Add(CkPfx__lastErrorText(pfx));
    Exit;
  end;
Memo1.Lines.Add('Loaded ' + IntToStr(CkPfx_getNumCerts(pfx)) + ' certificate(s).');

CkPfx_Dispose(pfx);
CkBinData_Dispose(bd);