Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Pfx
string ls_Password
string ls_EncodedPfx

li_Success = 0

loo_Pfx = create oleobject
li_rc = loo_Pfx.ConnectToNewObject("Chilkat.Pfx")
if li_rc < 0 then
    destroy loo_Pfx
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

//  Decode the base64 text into PFX / PKCS#12 bytes and load them.  Common encodings include base64
//  and hex.
ls_EncodedPfx = "MIIKrAIBAzCCCm...base64-encoded-pfx..."
li_Success = loo_Pfx.LoadPfxEncoded(ls_EncodedPfx,"base64",ls_Password)
if li_Success = 0 then
    Write-Debug loo_Pfx.LastErrorText
    destroy loo_Pfx
    return
end if

Write-Debug "Loaded " + string(loo_Pfx.NumCerts) + " certificate(s)."


destroy loo_Pfx