From a2960a3318743cc4ea85c868c9c9b6d4ce692a55 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 13 Jun 2019 13:53:55 +0200 Subject: [PATCH] [HttpClient] Don't use CurlHttpClient on Windows when curl.cainfo is not set --- src/Symfony/Component/HttpClient/HttpClient.php | 6 +++++- src/Symfony/Component/HttpClient/Response/CurlResponse.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpClient/HttpClient.php b/src/Symfony/Component/HttpClient/HttpClient.php index 25d3f6f874..f4da6ba686 100644 --- a/src/Symfony/Component/HttpClient/HttpClient.php +++ b/src/Symfony/Component/HttpClient/HttpClient.php @@ -32,7 +32,11 @@ final class HttpClient public static function create(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50): HttpClientInterface { if (\extension_loaded('curl')) { - return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes); + if ('\\' !== \DIRECTORY_SEPARATOR || ini_get('curl.cainfo') || ini_get('openssl.cafile') || ini_get('openssl.capath')) { + return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes); + } + + @trigger_error('Configure the "curl.cainfo", "openssl.cafile" or "openssl.capath" php.ini setting to enable the CurlHttpClient', E_USER_WARNING); } return new NativeHttpClient($defaultOptions, $maxHostConnections); diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 0c615bab04..14d3f935e0 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -336,7 +336,7 @@ final class CurlResponse implements ResponseInterface return 0; } - if ($certinfo = curl_getinfo($ch, CURLINFO_CERTINFO)) { + if (\function_exists('openssl_x509_read') && $certinfo = curl_getinfo($ch, CURLINFO_CERTINFO)) { $info['peer_certificate_chain'] = array_map('openssl_x509_read', array_column($certinfo, 'Cert')); }