1--TEST-- 2#46127 php_openssl_tcp_sockop_accept forgets to set context on accepted stream 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$certFile = __DIR__ . DIRECTORY_SEPARATOR . 'bug46127.pem.tmp'; 11 12$serverCode = <<<'CODE' 13 $serverUri = "ssl://127.0.0.1:64321"; 14 $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; 15 $serverCtx = stream_context_create(['ssl' => [ 16 'local_cert' => '%s', 17 ]]); 18 19 $sock = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); 20 phpt_notify(); 21 22 $link = stream_socket_accept($sock); 23 fwrite($link, "Sending bug 46127\n"); 24CODE; 25$serverCode = sprintf($serverCode, $certFile); 26 27$clientCode = <<<'CODE' 28 $serverUri = "ssl://127.0.0.1:64321"; 29 $clientFlags = STREAM_CLIENT_CONNECT; 30 31 $clientCtx = stream_context_create(['ssl' => [ 32 'verify_peer' => false, 33 'verify_peer_name' => false 34 ]]); 35 36 phpt_wait(); 37 $sock = stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx); 38 39 echo fgets($sock); 40CODE; 41 42include 'CertificateGenerator.inc'; 43$certificateGenerator = new CertificateGenerator(); 44$certificateGenerator->saveNewCertAsFileWithKey('bug46127', $certFile); 45 46include 'ServerClientTestCase.inc'; 47ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 48?> 49--CLEAN-- 50<?php 51@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'bug46127.pem.tmp'); 52?> 53--EXPECT-- 54Sending bug 46127 55