1--TEST-- 2tls stream wrapper when TLS 1.3 available 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 . 'tls_wrapper_with_tls_v1.3.pem.tmp'; 13 14$serverCode = <<<'CODE' 15 $flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN; 16 $ctx = stream_context_create(['ssl' => [ 17 'local_cert' => '%s', 18 'security_level' => 0, 19 ]]); 20 21 $server = stream_socket_server('tls://127.0.0.1:64321', $errno, $errstr, $flags, $ctx); 22 phpt_notify(); 23 24 for ($i = 0; $i < (phpt_has_sslv3() ? 7 : 6); $i++) { 25 @stream_socket_accept($server, 3); 26 } 27CODE; 28$serverCode = sprintf($serverCode, $certFile); 29 30$clientCode = <<<'CODE' 31 $flags = STREAM_CLIENT_CONNECT; 32 $ctx = stream_context_create(['ssl' => [ 33 'verify_peer' => false, 34 'verify_peer_name' => false, 35 'security_level' => 0, 36 ]]); 37 38 phpt_wait(); 39 40 $client = stream_socket_client("tlsv1.0://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx); 41 var_dump($client); 42 43 $client = @stream_socket_client("sslv3://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx); 44 var_dump($client); 45 46 $client = @stream_socket_client("tlsv1.1://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx); 47 var_dump($client); 48 49 $client = @stream_socket_client("tlsv1.2://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx); 50 var_dump($client); 51 52 $client = @stream_socket_client("tlsv1.3://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx); 53 var_dump($client); 54 55 $client = @stream_socket_client("ssl://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx); 56 var_dump($client); 57 58 $client = @stream_socket_client("tls://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx); 59 var_dump($client); 60CODE; 61 62include 'CertificateGenerator.inc'; 63$certificateGenerator = new CertificateGenerator(); 64$certificateGenerator->saveNewCertAsFileWithKey('tls_wrapper_with_tls_v1.3', $certFile); 65 66include 'ServerClientTestCase.inc'; 67ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 68?> 69--CLEAN-- 70<?php 71@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'tls_wrapper_with_tls_v1.3.pem.tmp'); 72?> 73--EXPECTF-- 74resource(%d) of type (stream) 75bool(false) 76resource(%d) of type (stream) 77resource(%d) of type (stream) 78resource(%d) of type (stream) 79resource(%d) of type (stream) 80resource(%d) of type (stream) 81