Sample code for 30+ languages & platforms
PowerBuilder

Set a TLS Client Certificate from a PEM

See more Socket/SSL/TLS Examples

Demonstrates Socket.SetSslClientCertPem, which loads and configures a TLS client certificate and private key from PEM data or a PEM 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. Supply the PEM password when the private key is encrypted, and configure the client certificate before connecting. Use client certificates only for mutual TLS.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Socket
string ls_PemPassword
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 PEM password should come from a secure source rather than being hard-coded.
ls_PemPassword = "myPemPassword"

//  Load and configure the TLS client certificate and private key from a PEM file.  Configure the
//  client certificate before connecting.
li_Success = loo_Socket.SetSslClientCertPem("qa_data/client.pem",ls_PemPassword)
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