Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/Tinify/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ function __construct($key, $app_identifier = NULL, $proxy = NULL) {
throw new ClientException("Your curl version {$version} is outdated; please upgrade to 7.18.1 or higher");
}

# Set minimum TLS version to 1.2, CURL_SSLVERSION_TLSv1_2 is not available in curl < 7.34.0
# Additionally old PHP versions may not support this constant
$tlsVersion = ($curl["version_number"] < 0x072200)
? 6
: (defined('CURL_SSLVERSION_TLSv1_2') ? CURL_SSLVERSION_TLSv1_2 : 6);
$this->options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_USERPWD => "api:" . $key,
CURLOPT_CAINFO => self::caBundle(),
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_USERAGENT => join(" ", array_filter(array(self::userAgent(), $app_identifier))),
CURLOPT_SSLVERSION => $tlsVersion,
);

if ($proxy) {
Expand Down