1--TEST-- 2Capture SSL session meta array in stream context for TLSv1.3 3--EXTENSIONS-- 4openssl 5--SKIPIF-- 6<?php 7if (!function_exists("proc_open")) die("skip no proc_open"); 8if (OPENSSL_VERSION_NUMBER < 0x10101000) die("skip OpenSSL v1.1.1 required"); 9?> 10--FILE-- 11<?php 12$certFile = __DIR__ . DIRECTORY_SEPARATOR . 'session_meta_capture_tlsv13.pem.tmp'; 13$cacertFile = __DIR__ . DIRECTORY_SEPARATOR . 'session_meta_capture_tlsv13-ca.pem.tmp'; 14 15$serverCode = <<<'CODE' 16 $serverUri = "ssl://127.0.0.1:64321"; 17 $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; 18 $serverCtx = stream_context_create(['ssl' => [ 19 'local_cert' => '%s', 20 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_3_SERVER, 21 ]]); 22 23 $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); 24 phpt_notify(); 25 26 @stream_socket_accept($server, 1); 27CODE; 28$serverCode = sprintf($serverCode, $certFile); 29 30$peerName = 'session_meta_capture_tlsv13'; 31$clientCode = <<<'CODE' 32 $serverUri = "ssl://127.0.0.1:64321"; 33 $clientFlags = STREAM_CLIENT_CONNECT; 34 $clientCtx = stream_context_create(['ssl' => [ 35 'verify_peer' => true, 36 'cafile' => '%s', 37 'peer_name' => '%s' 38 ]]); 39 40 phpt_wait(); 41 42 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT); 43 $stream = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); 44 var_dump(stream_get_meta_data($stream)['crypto']['protocol']); 45CODE; 46$clientCode = sprintf($clientCode, $cacertFile, $peerName); 47 48include 'CertificateGenerator.inc'; 49$certificateGenerator = new CertificateGenerator(); 50$certificateGenerator->saveCaCert($cacertFile); 51$certificateGenerator->saveNewCertAsFileWithKey($peerName, $certFile); 52 53include 'ServerClientTestCase.inc'; 54ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 55?> 56--EXPECT-- 57string(7) "TLSv1.3" 58