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