From 8eb8a7c400e0e0dedb8b3ab157fcb5788fa4a7db Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 2 Oct 2020 11:43:10 +0200 Subject: [PATCH] [HttpClient] fix unsetting context[ssl][peer_name] --- src/Symfony/Component/HttpClient/Response/NativeResponse.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/HttpClient/Response/NativeResponse.php b/src/Symfony/Component/HttpClient/Response/NativeResponse.php index c06df1afb0..e29005b58f 100644 --- a/src/Symfony/Component/HttpClient/Response/NativeResponse.php +++ b/src/Symfony/Component/HttpClient/Response/NativeResponse.php @@ -135,6 +135,11 @@ final class NativeResponse implements ResponseInterface $this->info['request_header'] = sprintf("> %s %s HTTP/%s \r\n", $context['http']['method'], $this->info['request_header'], $context['http']['protocol_version']); $this->info['request_header'] .= implode("\r\n", $context['http']['header'])."\r\n\r\n"; + if (\array_key_exists('peer_name', $context['ssl']) && null === $context['ssl']['peer_name']) { + unset($context['ssl']['peer_name']); + $this->context = stream_context_create([], ['options' => $context] + stream_context_get_params($this->context)); + } + // Send request and follow redirects when needed $this->handle = $h = fopen($url, 'r', false, $this->context); self::addResponseHeaders($http_response_header, $this->info, $this->headers, $this->info['debug']);