@@ -142,6 +142,16 @@ public function testSecureHttpsOnRandomPort()
142142 ]]);
143143 $ http ->listen ($ socket );
144144
145+ // clear OpenSSL errors from closing the server side before the client reads,
146+ // as legacy PHP < 7.2 does not (https://bugs.php.net/bug.php?id=78775)
147+ $ socket ->on ('connection ' , function (ConnectionInterface $ conn ) {
148+ $ conn ->on ('close ' , function () {
149+ Loop ::futureTick (function () {
150+ while (openssl_error_string () !== false );
151+ });
152+ });
153+ });
154+
145155 $ result = $ connector ->connect ($ socket ->getAddress ())->then (function (ConnectionInterface $ conn ) {
146156 $ conn ->write ("GET / HTTP/1.0 \r\nHost: " . noScheme ($ conn ->getRemoteAddress ()) . "\r\n\r\n" );
147157
@@ -169,6 +179,16 @@ public function testSecureHttpsReturnsData()
169179 $ socket = new SocketServer ('tls://127.0.0.1:0 ' , ['tls ' => ['local_cert ' => __DIR__ . '/../examples/localhost.pem ' ]]);
170180 $ http ->listen ($ socket );
171181
182+ // clear OpenSSL errors from closing the server side before the client reads,
183+ // as legacy PHP < 7.2 does not (https://bugs.php.net/bug.php?id=78775)
184+ $ socket ->on ('connection ' , function (ConnectionInterface $ conn ) {
185+ $ conn ->on ('close ' , function () {
186+ Loop ::futureTick (function () {
187+ while (openssl_error_string () !== false );
188+ });
189+ });
190+ });
191+
172192 $ connector = new Connector (['tls ' => [
173193 'verify_peer ' => false
174194 ]]);
@@ -203,6 +223,16 @@ public function testSecureHttpsOnRandomPortWithoutHostHeaderUsesSocketUri()
203223 ]]);
204224 $ http ->listen ($ socket );
205225
226+ // clear OpenSSL errors from closing the server side before the client reads,
227+ // as legacy PHP < 7.2 does not (https://bugs.php.net/bug.php?id=78775)
228+ $ socket ->on ('connection ' , function (ConnectionInterface $ conn ) {
229+ $ conn ->on ('close ' , function () {
230+ Loop ::futureTick (function () {
231+ while (openssl_error_string () !== false );
232+ });
233+ });
234+ });
235+
206236 $ result = $ connector ->connect ($ socket ->getAddress ())->then (function (ConnectionInterface $ conn ) {
207237 $ conn ->write ("GET / HTTP/1.0 \r\n\r\n" );
208238
0 commit comments