1--TEST-- 2Capture SSL session meta array in stream context 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 @stream_socket_accept($server, 1); 21 @stream_socket_accept($server, 1); 22 @stream_socket_accept($server, 1); 23 @stream_socket_accept($server, 1); 24CODE; 25 26$clientCode = <<<'CODE' 27 $serverUri = "ssl://127.0.0.1:64321"; 28 $clientFlags = STREAM_CLIENT_CONNECT; 29 $clientCtx = stream_context_create(['ssl' => [ 30 'verify_peer' => true, 31 'cafile' => __DIR__ . '/bug54992-ca.pem', 32 'peer_name' => 'bug54992.local', 33 'capture_session_meta' => true, 34 ]]); 35 36 phpt_wait(); 37 38 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT); 39 @stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); 40 $meta = stream_context_get_options($clientCtx)['ssl']['session_meta']; 41 var_dump($meta['protocol']); 42 43 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT); 44 @stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); 45 $meta = stream_context_get_options($clientCtx)['ssl']['session_meta']; 46 var_dump($meta['protocol']); 47 48 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); 49 @stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx); 50 $meta = stream_context_get_options($clientCtx)['ssl']['session_meta']; 51 var_dump($meta['protocol']); 52CODE; 53 54include 'ServerClientTestCase.inc'; 55ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 56?> 57--EXPECTF-- 58string(5) "TLSv1" 59string(7) "TLSv1.1" 60string(7) "TLSv1.2" 61