Sample code for 30+ languages & platforms
PowerBuilder

Load a PFX from a File

See more PFX/P12 Examples

Demonstrates Pfx.LoadPfxFile, which loads a PFX / PKCS#12 container from a file path, using the supplied password to decrypt it.

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. A PFX (PKCS#12) container bundles one or more certificates together with their private keys. After loading, the certificates and keys can be enumerated and used.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Pfx
string ls_Password

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 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.
//  The PFX password should come from a secure source rather than being hard-coded.
ls_Password = "myPfxPassword"

//  Load a PFX / PKCS#12 container from a file.
li_Success = loo_Pfx.LoadPfxFile("qa_data/identity.pfx",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) and " + string(loo_Pfx.NumPrivateKeys) + " private key(s)."


destroy loo_Pfx