Skip to content

Commit b9e1461

Browse files
committed
Add configurable TLS version and cipher suite support
1 parent 1ed6d53 commit b9e1461

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

lib/ApiClient.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,19 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
349349
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $this->config->getCurlProxyUser() . ':' .$this->config->getCurlProxyPassword());
350350
}
351351

352+
if ($this->config->getTlsVersion()) {
353+
curl_setopt($curl, CURLOPT_SSLVERSION, $this->config->getTlsVersion());
354+
}
355+
356+
if ($this->config->getTlsCipherList()) {
357+
// use TLS 1.3 ciphers for TLS 1.3, otherwise use general SSL cipher list
358+
if ($this->config->getTlsVersion() && $this->config->getTlsVersion() === CURL_SSLVERSION_TLSv1_3) {
359+
curl_setopt($curl, CURLOPT_TLS13_CIPHERS, $this->config->getTlsCipherList());
360+
} else {
361+
curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, $this->config->getTlsCipherList());
362+
}
363+
}
364+
352365
if (!empty($queryParams)) {
353366
$url = ($url . '?' . http_build_query($queryParams));
354367
}

lib/Configuration.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ class Configuration
173173
*/
174174
protected $allowEncoding = false;
175175

176+
/**
177+
* TLS version to use for HTTPS requests
178+
*
179+
* @var string
180+
*/
181+
protected $tlsVersion;
182+
183+
/**
184+
* TLS cipher list to use for HTTPS requests
185+
*
186+
* @var string
187+
*/
188+
protected $tlsCipherList;
189+
176190
/**
177191
* Logging configuration
178192
*
@@ -572,6 +586,53 @@ public function getLogConfiguration()
572586
return $this->logConfig;
573587
}
574588

589+
590+
/**
591+
* Sets the TLS version to use for HTTPS requests
592+
*
593+
* @param string $tlsVersion TLS version (e.g. CURL_SSLVERSION_TLSv1_2)
594+
*
595+
* @return $this
596+
*/
597+
public function setTlsVersion($tlsVersion)
598+
{
599+
$this->tlsVersion = $tlsVersion;
600+
return $this;
601+
}
602+
603+
/**
604+
* Gets the TLS version to use for HTTPS requests
605+
*
606+
* @return string TLS version
607+
*/
608+
public function getTlsVersion()
609+
{
610+
return $this->tlsVersion;
611+
}
612+
613+
/**
614+
* Sets the TLS cipher list to use for HTTPS requests
615+
*
616+
* @param string $tlsCipherList TLS cipher list
617+
*
618+
* @return $this
619+
*/
620+
public function setTlsCipherList($tlsCipherList)
621+
{
622+
$this->tlsCipherList = $tlsCipherList;
623+
return $this;
624+
}
625+
626+
/**
627+
* Gets the TLS cipher list to use for HTTPS requests
628+
*
629+
* @return string TLS cipher list
630+
*/
631+
public function getTlsCipherList()
632+
{
633+
return $this->tlsCipherList;
634+
}
635+
575636
/**
576637
* Sets the HTTP Proxy Host
577638
*

0 commit comments

Comments
 (0)