Sample code for 30+ languages & platforms
Lianja

Load PFX/P12 from a Base64 Encoded PFX File

See more PFX/P12 Examples

Demonstrates how to call LoadPfxEncoded.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loBd = createobject("CkBinData")

llSuccess = loBd.LoadFile("qa_data/pfx/cert_test123.pfx")
if (llSuccess <> .T.) then
    ? "Failed to load PFX file."
    release loBd
    return
endif

// Get the bytes contained in the PFX in base64 format:
lcStrBase64 = loBd.GetEncoded("base64")

// The base64 looks like this:  "MIIbEAIBAzCCGswGCSqGSIb3DQEHAaCCGr0Eghq5MIIatTCCBg..."
? lcStrBase64

loPfx = createobject("CkPfx")

// Load the PFX from the base64 string
lcPassword = "test123"
llSuccess = loPfx.LoadPfxEncoded(lcStrBase64,"base64",lcPassword)
if (llSuccess <> .T.) then
    ? loPfx.LastErrorText
    release loBd
    release loPfx
    return
endif

? "success"


release loBd
release loPfx