For HTTPClient and RestClient objects

Applies to

HTTPClient, RestClient

Description

The SecureProtocol property specifies the security protocol. Values are:

0 – All security protocols. This is the default value. It will detect and use the security protocol in the following order: TLS 1.3, TLS 1.2, TLS 1.1, SSL 2.0, SSL 3.0, TLS 1.0.

1 – SSL 2

2 – SSL 3

3 – TLS 1.0

4 – TLS 1.1

5 – TLS 1.2

6 – TLS 1.3 (experimental). Currently the PowerBuilder native C/S application can support TLS 1.3 only when running in Windows 11 or Windows Server 2022.

Usage

In a painter

To set the security protocol:

  • Select the security protocol from the SecureProtocol list on the General page in the object's Properties view.

In scripts

The SecureProtocol property takes an integer value. The following example sets the SecureProtocol property to use TLS 1.0:

HttpClient lnv_HttpClient 
lnv_HttpClient = Create HttpClient

Constant Integer SECURE_PROTOCOL_TLS1 = 3

// Set security protocol to TLS1.0
lnv_HttpClient.SecureProtocol = SECURE_PROTOCOL_TLS1 // default is 0, means all security protocols except TLS 1.3

// Send GET request
lnv_HttpClient.SendRequest("GET", "https://demo.appeon.com/PB/webapi_client/employee/102")

The following example sets the SecureProtocol property to use TLS 1.3, and if TLS 1.3 is not available, uses the security protocol that is detected in the following order: TLS 1.2, TLS 1.1, SSL 2.0, SSL 3.0, TLS 1.0:

l_httpclient.secureProtocol= 6
ln_rtn = l_httpclient.SendRequest("GET", "https://test.appeon.com")
if ln_rtn = -19 then
  l_httpclient.secureProtocol= 0
  ln_rtn = l_httpclient.SendRequest("GET", "https://test.appeon.com")
end if
l_restclient.secureProtocol= 6
ln_rtn = l_restclient.SendGetRequest("https://test.appeon.com")
if ln_rtn = -33 then
  l_restclient.secureProtocol= 0
  ln_rtn = l_restclient.SendGetRequest("https://test.appeon.com")
end if