1--TEST--
2tls stream wrapper with min version 1.0 and max version 1.1
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 . 'tls_min_v1.0_max_v1.1_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        'min_proto_version' => STREAM_CRYPTO_PROTO_TLSv1_0,
18        'max_proto_version' => STREAM_CRYPTO_PROTO_TLSv1_1,
19        'security_level' => 0,
20    ]]);
21
22    $server = stream_socket_server('tls://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
23    phpt_notify();
24
25    for ($i=0; $i < (phpt_has_sslv3() ? 6 : 5); $i++) {
26        @stream_socket_accept($server, 3);
27    }
28CODE;
29$serverCode = sprintf($serverCode, $certFile);
30
31$clientCode = <<<'CODE'
32    $flags = STREAM_CLIENT_CONNECT;
33    $ctx = stream_context_create(['ssl' => [
34        'verify_peer' => false,
35        'verify_peer_name' => false,
36        'security_level' => 0,
37    ]]);
38
39    phpt_wait();
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("sslv3://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
45    var_dump($client);
46
47    $client = @stream_socket_client("tlsv1.1://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
48    var_dump($client);
49
50    $client = @stream_socket_client("tlsv1.2://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
51    var_dump($client);
52
53    $client = @stream_socket_client("ssl://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
54    var_dump($client);
55
56    $client = @stream_socket_client("tls://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
57    var_dump($client);
58CODE;
59
60include 'CertificateGenerator.inc';
61$certificateGenerator = new CertificateGenerator();
62$certificateGenerator->saveNewCertAsFileWithKey('tls_min_v1.0_max_v1.1_wrapper', $certFile);
63
64include 'ServerClientTestCase.inc';
65ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
66?>
67--CLEAN--
68<?php
69@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'tls_min_v1.0_max_v1.1_wrapper.pem.tmp');
70?>
71--EXPECTF--
72resource(%d) of type (stream)
73bool(false)
74resource(%d) of type (stream)
75bool(false)
76resource(%d) of type (stream)
77resource(%d) of type (stream)
78