Skip to content

Commit 43ef038

Browse files
committed
Set minimum TLS version to v1.2
1 parent 8386ac9 commit 43ef038

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/Tinify/Client.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ function __construct($key, $app_identifier = NULL, $proxy = NULL) {
3131
throw new ClientException("Your curl version {$version} is outdated; please upgrade to 7.18.1 or higher");
3232
}
3333

34+
# Set minimum TLS version to 1.2, CURL_SSLVERSION_TLSv1_2 is not available in curl < 7.34.0
35+
# Additionally old PHP versions may not support this constant
36+
$tlsVersion = ($curl["version_number"] < 0x072200)
37+
? 6
38+
: (defined('CURL_SSLVERSION_TLSv1_2') ? CURL_SSLVERSION_TLSv1_2 : 6);
3439
$this->options = array(
3540
CURLOPT_RETURNTRANSFER => true,
3641
CURLOPT_HEADER => true,
3742
CURLOPT_USERPWD => "api:" . $key,
3843
CURLOPT_CAINFO => self::caBundle(),
3944
CURLOPT_SSL_VERIFYPEER => true,
4045
CURLOPT_USERAGENT => join(" ", array_filter(array(self::userAgent(), $app_identifier))),
46+
CURLOPT_SSLVERSION => $tlsVersion,
4147
);
4248

4349
if ($proxy) {

0 commit comments

Comments
 (0)