Skip to content

Commit

Permalink
Prevent error on systems with older cURL compile target
Browse files Browse the repository at this point in the history
On systems, where the PHP cURL extension is compiled against an older version of cURL without support for public key pinning (e.g. the builds from https://rpms.remirepo.net/ for RHEL/CentOS 7), the CurlHttpDriver fails with a 500 error, stating that the constant CURLOPT_PINNEDPUBLICKEY is not found. For the worse this happens even when the PHP installation itself uses a newer cURL, but the extension doesn't know about that constant and its corresponding cURL option.

This PR adds a feature test to omit the certificate pinning on systems that don't support it (i.e. where the constant is not defined), otherwise the whole Threema-API cannot be used at all on those systems.
  • Loading branch information
spackmat committed May 25, 2021
1 parent 4010708 commit afbede0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Threema/MsgApi/HttpDriver/CurlHttpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function createDefaultOptions(\Closure $progress = null): array
}

$pinnedKey = $this->tlsOptions[self::tlsOptionPinnedKey];
if (!empty($pinnedKey)) {
if (defined('CURLOPT_PINNEDPUBLICKEY') && !empty($pinnedKey)) {
$options[CURLOPT_PINNEDPUBLICKEY] = $pinnedKey;
}

Expand Down

0 comments on commit afbede0

Please sign in to comment.