From 8feb83b22bde7658e901524502d4a64603322baa Mon Sep 17 00:00:00 2001 From: johnstevenson Date: Tue, 29 Sep 2020 13:04:30 +0100 Subject: [PATCH] Remove duplicate StreamContextFactory ssl options Added in Dec 2014 (commit 8dad846), superseded in Jan 2016 (pr #4759) --- src/Composer/Util/StreamContextFactory.php | 8 ---- .../Test/Util/StreamContextFactoryTest.php | 46 ++++++------------- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/src/Composer/Util/StreamContextFactory.php b/src/Composer/Util/StreamContextFactory.php index 5fe3815c5..d81119aff 100644 --- a/src/Composer/Util/StreamContextFactory.php +++ b/src/Composer/Util/StreamContextFactory.php @@ -130,14 +130,6 @@ final class StreamContextFactory break; } - // add SNI opts for https URLs - if ('https' === parse_url($url, PHP_URL_SCHEME)) { - $options['ssl']['SNI_enabled'] = true; - if (PHP_VERSION_ID < 50600) { - $options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST); - } - } - // handle proxy auth if present if (isset($proxy['user'])) { $auth = rawurldecode($proxy['user']); diff --git a/tests/Composer/Test/Util/StreamContextFactoryTest.php b/tests/Composer/Test/Util/StreamContextFactoryTest.php index a3bb3941f..973ff3254 100644 --- a/tests/Composer/Test/Util/StreamContextFactoryTest.php +++ b/tests/Composer/Test/Util/StreamContextFactoryTest.php @@ -129,22 +129,13 @@ class StreamContextFactoryTest extends TestCase $context = StreamContextFactory::getContext('https://example.org', array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo'))); $options = stream_context_get_options($context); - $expected = array( - 'http' => array( - 'proxy' => 'tcp://proxyserver.net:80', - 'method' => 'GET', - 'header' => array('User-Agent: foo', "Proxy-Authorization: Basic " . base64_encode('username:password')), - 'max_redirects' => 20, - 'follow_location' => 1, - ), 'ssl' => array( - 'SNI_enabled' => true, - 'SNI_server_name' => 'example.org', - ), - ); - if (PHP_VERSION_ID >= 50600) { - unset($expected['ssl']['SNI_server_name']); - } - $this->assertEquals($expected, $options); + $this->assertEquals(array('http' => array( + 'proxy' => 'tcp://proxyserver.net:80', + 'method' => 'GET', + 'header' => array('User-Agent: foo', "Proxy-Authorization: Basic " . base64_encode('username:password')), + 'max_redirects' => 20, + 'follow_location' => 1, + )), $options); } public function testHttpsProxyOverride() @@ -159,22 +150,13 @@ class StreamContextFactoryTest extends TestCase $context = StreamContextFactory::getContext('https://example.org', array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo'))); $options = stream_context_get_options($context); - $expected = array( - 'http' => array( - 'proxy' => 'ssl://woopproxy.net:443', - 'method' => 'GET', - 'max_redirects' => 20, - 'follow_location' => 1, - 'header' => array('User-Agent: foo'), - ), 'ssl' => array( - 'SNI_enabled' => true, - 'SNI_server_name' => 'example.org', - ), - ); - if (PHP_VERSION_ID >= 50600) { - unset($expected['ssl']['SNI_server_name']); - } - $this->assertEquals($expected, $options); + $this->assertEquals(array('http' => array( + 'proxy' => 'ssl://woopproxy.net:443', + 'method' => 'GET', + 'max_redirects' => 20, + 'follow_location' => 1, + 'header' => array('User-Agent: foo'), + )), $options); } /**