From 8cec8bd5460b897cca772cb312d281bc64f0c7ad Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 17 Jul 2020 17:22:41 +0200 Subject: [PATCH] Allow verify_peer/verify_peer_name http options to be handled by curl downloader --- src/Composer/Util/Http/CurlDownloader.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Composer/Util/Http/CurlDownloader.php b/src/Composer/Util/Http/CurlDownloader.php index 257a29115..b2219fbc5 100644 --- a/src/Composer/Util/Http/CurlDownloader.php +++ b/src/Composer/Util/Http/CurlDownloader.php @@ -56,6 +56,8 @@ class CurlDownloader 'ssl' => array( 'cafile' => CURLOPT_CAINFO, 'capath' => CURLOPT_CAPATH, + 'verify_peer' => CURLOPT_SSL_VERIFYPEER, + 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST, ), ); @@ -178,7 +180,11 @@ class CurlDownloader foreach (self::$options as $type => $curlOptions) { foreach ($curlOptions as $name => $curlOption) { if (isset($options[$type][$name])) { - curl_setopt($curlHandle, $curlOption, $options[$type][$name]); + if ($type === 'ssl' && $name === 'verify_peer_name') { + curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]); + } else { + curl_setopt($curlHandle, $curlOption, $options[$type][$name]); + } } } }