PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Pfx
oleobject loo_Bd
integer li_BLoaded
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.
// Load the PFX bytes into a BinData.
loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")
li_BLoaded = loo_Bd.LoadFile("qa_data/identity.pfx")
if li_BLoaded <> 1 then
Write-Debug "Failed to load the PFX file."
destroy loo_Pfx
destroy loo_Bd
return
end if
// The PFX password should come from a secure source rather than being hard-coded.
ls_Password = "myPfxPassword"
// Load the PFX / PKCS#12 container from the bytes held in the BinData.
li_Success = loo_Pfx.LoadPfxBd(loo_Bd,ls_Password)
if li_Success = 0 then
Write-Debug loo_Pfx.LastErrorText
destroy loo_Pfx
destroy loo_Bd
return
end if
Write-Debug "Loaded " + string(loo_Pfx.NumCerts) + " certificate(s)."
destroy loo_Pfx
destroy loo_Bd