Sample code for 30+ languages & platforms
PowerBuilder

Set a TLS Client Certificate from a PFX

See more Socket/SSL/TLS Examples

Demonstrates Socket.SetSslClientCertPfx, which loads and configures a TLS client certificate and private key from a PFX/P12 file.

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. Configure the client certificate before connecting. Use client certificates only when the server requests or requires client-certificate authentication (mutual TLS).

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Socket
string ls_PfxPassword
integer li_BTls
integer li_MaxWaitMs

li_Success = 0

loo_Socket = create oleobject
li_rc = loo_Socket.ConnectToNewObject("Chilkat.Socket")
if li_rc < 0 then
    destroy loo_Socket
    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_PfxPassword = "myPfxPassword"

//  Load and configure the TLS client certificate and private key from a PFX/P12 file.  Configure the
//  client certificate before connecting.
li_Success = loo_Socket.SetSslClientCertPfx("qa_data/client.pfx",ls_PfxPassword)
if li_Success = 0 then
    Write-Debug loo_Socket.LastErrorText
    destroy loo_Socket
    return
end if

li_BTls = 1
li_MaxWaitMs = 5000
li_Success = loo_Socket.Connect("example.com",5000,li_BTls,li_MaxWaitMs)
if li_Success = 0 then
    Write-Debug loo_Socket.LastErrorText
    destroy loo_Socket
    return
end if

Write-Debug "Connected with mutual TLS."


destroy loo_Socket