1--TEST--
2tlsv1.3 stream wrapper
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 . 'tlsv1.3_wrapper.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    ]]);
19
20    $server = stream_socket_server('tlsv1.3://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
21    phpt_notify();
22
23    for ($i=0; $i < 3; $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    ]]);
35
36    phpt_wait();
37
38    $client = stream_socket_client("tlsv1.3://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
39    var_dump($client);
40
41    $client = @stream_socket_client("tlsv1.0://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
42    var_dump($client);
43
44    $client = @stream_socket_client("tlsv1.2://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
45    var_dump($client);
46CODE;
47
48include 'CertificateGenerator.inc';
49$certificateGenerator = new CertificateGenerator();
50$certificateGenerator->saveNewCertAsFileWithKey('tlsv1.3_wrapper', $certFile);
51
52include 'ServerClientTestCase.inc';
53ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
54?>
55--CLEAN--
56<?php
57@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'tlsv1.3_wrapper.pem.tmp');
58?>
59--EXPECTF--
60resource(%d) of type (stream)
61bool(false)
62bool(false)
63