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