Skip to content

Commit e8ec3af

Browse files
author
Kyra Farrow
committed
[HttpClient] Don't use CurlHttpClient on Windows when curl.cainfo is not set
1 parent 89a4da6 commit e8ec3af

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

HttpClient.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ final class HttpClient
3232
public static function create(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50): HttpClientInterface
3333
{
3434
if (\extension_loaded('curl')) {
35-
return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes);
35+
if ('\\' !== \DIRECTORY_SEPARATOR || ini_get('curl.cainfo') || ini_get('openssl.cafile') || ini_get('openssl.capath')) {
36+
return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes);
37+
}
38+
39+
@trigger_error('Configure the "curl.cainfo", "openssl.cafile" or "openssl.capath" php.ini setting to enable the CurlHttpClient', E_USER_WARNING);
3640
}
3741

3842
return new NativeHttpClient($defaultOptions, $maxHostConnections);

Response/CurlResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &
336336
return 0;
337337
}
338338

339-
if ($certinfo = curl_getinfo($ch, CURLINFO_CERTINFO)) {
339+
if (\function_exists('openssl_x509_read') && $certinfo = curl_getinfo($ch, CURLINFO_CERTINFO)) {
340340
$info['peer_certificate_chain'] = array_map('openssl_x509_read', array_column($certinfo, 'Cert'));
341341
}
342342

0 commit comments

Comments
 (0)