Sample code for 30+ languages & platforms
Delphi DLL

Load a PFX from an Encoded String

See more PFX/P12 Examples

Demonstrates Pfx.LoadPfxEncoded, which decodes text using a named binary encoding (such as base64) and loads the resulting bytes as a PFX / PKCS#12 container.

Background. This is useful when the PKCS#12 data has been transported or stored as printable text, such as base64.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
pfx: HCkPfx;
password: PWideChar;
encodedPfx: PWideChar;

begin
success := False;

pfx := CkPfx_Create();

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

//  Decode the base64 text into PFX / PKCS#12 bytes and load them.  Common encodings include base64
//  and hex.
encodedPfx := 'MIIKrAIBAzCCCm...base64-encoded-pfx...';
success := CkPfx_LoadPfxEncoded(pfx,encodedPfx,'base64',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);