PowerBuilder
PowerBuilder
Export a PFX as PEM Text
See more PFX/P12 Examples
Demonstrates Pfx.ToPem, which exports all private keys and certificates currently held by the object as PEM-formatted text.
Background. Certificates are written as standard
BEGIN CERTIFICATE blocks. This converts PKCS#12 material into the widely used PEM format.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Pfx
string ls_Password
string ls_Pem
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"
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
// Export all private keys and certificates currently held by the object as PEM-formatted text.
ls_Pem = loo_Pfx.ToPem()
if loo_Pfx.LastMethodSuccess = 0 then
Write-Debug loo_Pfx.LastErrorText
destroy loo_Pfx
return
end if
Write-Debug ls_Pem
destroy loo_Pfx