From ff9ff5324c77be8ab7429142f425aff7f3f9d276 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 2 Jan 2020 11:45:12 +0100 Subject: [PATCH] [HttpClient] fix capturing SSL certificates with NativeHttpClient --- Response/NativeResponse.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Response/NativeResponse.php b/Response/NativeResponse.php index 49e25c5..383603d 100644 --- a/Response/NativeResponse.php +++ b/Response/NativeResponse.php @@ -158,13 +158,13 @@ private function open(): void restore_error_handler(); } - stream_set_blocking($h, false); - $this->context = $this->resolveRedirect = null; - - if (isset($context['ssl']['peer_certificate_chain'])) { + if (isset($context['ssl']['capture_peer_cert_chain']) && isset(($context = stream_context_get_options($this->context))['ssl']['peer_certificate_chain'])) { $this->info['peer_certificate_chain'] = $context['ssl']['peer_certificate_chain']; } + stream_set_blocking($h, false); + $this->context = $this->resolveRedirect = null; + // Create dechunk and inflate buffers if (isset($this->headers['content-length'])) { $this->remaining = (int) $this->headers['content-length'][0];