1--TEST-- 2Bug #48182: ssl handshake fails during asynchronous socket connection 3--SKIPIF-- 4<?php 5if (!extension_loaded("openssl")) die("skip openssl not loaded"); 6if (!function_exists("proc_open")) die("skip no proc_open"); 7?> 8--FILE-- 9<?php 10$serverCode = <<<'CODE' 11 $serverUri = "ssl://127.0.0.1:64321"; 12 $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; 13 $serverCtx = stream_context_create(['ssl' => [ 14 'local_cert' => __DIR__ . '/bug54992.pem' 15 ]]); 16 17 $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); 18 phpt_notify(); 19 20 $client = @stream_socket_accept($server, 1); 21 22 $data = "Sending bug48182\n" . fread($client, 8192); 23 fwrite($client, $data); 24CODE; 25 26$clientCode = <<<'CODE' 27 $serverUri = "ssl://127.0.0.1:64321"; 28 $clientFlags = STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT; 29 $clientCtx = stream_context_create(['ssl' => [ 30 'cafile' => __DIR__ . '/bug54992-ca.pem', 31 'peer_name' => 'bug54992.local' 32 ]]); 33 34 phpt_wait(); 35 $client = stream_socket_client($serverUri, $errno, $errstr, 10, $clientFlags, $clientCtx); 36 37 $data = "Sending data over to SSL server in async mode with contents like Hello World\n"; 38 39 fwrite($client, $data); 40 echo fread($client, 1024); 41CODE; 42 43echo "Running bug48182\n"; 44 45include 'ServerClientTestCase.inc'; 46ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 47?> 48--EXPECTF-- 49Running bug48182 50Sending bug48182 51Sending data over to SSL server in async mode with contents like Hello World 52