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