Sample code for 30+ languages & platforms
PowerBuilder

Load PFX with Different Password for Private Keys

See more PFX/P12 Examples

Demonstrates how to load a PFX where the HMAC integrity password (the password for the entire PFX) is different than the password for the private keys contained inside.

Note: This example requires a new feature made available in Chilkat v9.5.0.75.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Pfx
oleobject loo_Json

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
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

// Build JSON containing the HMAC integrity (PFX) password, and the 
// password for the private keys.
loo_Json.UpdateString("integrity","password1")
loo_Json.UpdateString("privKeys","password2")

// The JSON contains this:
// 
// 	{
// 	  "integrity": "password1",
// 	  "privKeys": "password2"
// 	}
// 

// Use the above JSON instead of a simple password string when loading the PFX:
li_Success = loo_Pfx.LoadPfxFile("qa_data/pfx/PrivateKeyPassIsDifferent.pfx",loo_Json.Emit())
if li_Success <> 1 then
    Write-Debug loo_Pfx.LastErrorText
    destroy loo_Pfx
    destroy loo_Json
    return
end if

Write-Debug "Success."


destroy loo_Pfx
destroy loo_Json