1--TEST--
2tlsv1.2 stream wrapper
3--EXTENSIONS--
4openssl
5--SKIPIF--
6<?php
7if (!function_exists("proc_open")) die("skip no proc_open");
8?>
9--FILE--
10<?php
11$certFile = __DIR__ . DIRECTORY_SEPARATOR . 'tlsv1.2_wrapper.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    ]]);
18
19    $server = stream_socket_server('tlsv1.2://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
20    phpt_notify();
21
22    for ($i = 0; $i < (phpt_has_sslv3() ? 3 : 2); $i++) {
23        @stream_socket_accept($server, 3);
24    }
25CODE;
26$serverCode = sprintf($serverCode, $certFile);
27
28$clientCode = <<<'CODE'
29    $flags = STREAM_CLIENT_CONNECT;
30    $ctx = stream_context_create(['ssl' => [
31        'verify_peer' => false,
32        'verify_peer_name' => false,
33    ]]);
34
35    phpt_wait();
36
37    $client = stream_socket_client("tlsv1.2://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
38    var_dump($client);
39
40    $client = @stream_socket_client("sslv3://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
41    var_dump($client);
42
43    $client = @stream_socket_client("tlsv1.1://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
44    var_dump($client);
45CODE;
46
47include 'CertificateGenerator.inc';
48$certificateGenerator = new CertificateGenerator();
49$certificateGenerator->saveNewCertAsFileWithKey('tlsv1.2_wrapper', $certFile);
50
51include 'ServerClientTestCase.inc';
52ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
53?>
54--CLEAN--
55<?php
56@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'tlsv1.2_wrapper.pem.tmp');
57?>
58--EXPECTF--
59resource(%d) of type (stream)
60bool(false)
61bool(false)
62