1--TEST-- 2Specific protocol method specification 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 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_0_SERVER, 16 ]]); 17 18 $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); 19 phpt_notify(); 20 21 @stream_socket_accept($server, 1); 22 @stream_socket_accept($server, 1); 23 @stream_socket_accept($server, 1); 24 @stream_socket_accept($server, 1); 25CODE; 26 27$clientCode = <<<'CODE' 28 $serverUri = "ssl://127.0.0.1:64321"; 29 $clientFlags = STREAM_CLIENT_CONNECT; 30 $clientCtx = stream_context_create(['ssl' => [ 31 'verify_peer' => true, 32 'cafile' => __DIR__ . '/bug54992-ca.pem', 33 'peer_name' => 'bug54992.local', 34 ]]); 35 36 phpt_wait(); 37 38 // Should succeed because the SSLv23 handshake here is compatible with the 39 // TLSv1 hello method employed in the server 40 var_dump(@stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx)); 41 42 // Should fail because the TLSv1.1 hello method is not supported 43 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT); 44 var_dump(@stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx)); 45 46 // Should fail because the TLSv1.2 hello method is not supported 47 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); 48 var_dump(@stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx)); 49 50 // Should succeed because we use the same TLSv1 hello 51 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT); 52 var_dump(stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx)); 53CODE; 54 55include 'ServerClientTestCase.inc'; 56ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 57?> 58--EXPECTF-- 59resource(%d) of type (stream) 60bool(false) 61bool(false) 62resource(%d) of type (stream) 63