1--TEST--
2Basic bitwise stream crypto context flag assignment
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$serverCode = <<<'CODE'
11    $serverUri = "ssl://127.0.0.1:64321";
12    $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
13    $serverCtx = stream_context_create(['ssl' => [
14        'local_cert' => __DIR__ . '/bug54992.pem'
15    ]]);
16
17    $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
18    phpt_notify();
19
20    @stream_socket_accept($server, 1);
21    @stream_socket_accept($server, 1);
22    @stream_socket_accept($server, 1);
23CODE;
24
25$clientCode = <<<'CODE'
26    $serverUri = "ssl://127.0.0.1:64321";
27    $clientFlags = STREAM_CLIENT_CONNECT;
28    $clientCtx = stream_context_create(['ssl' => [
29        'verify_peer' => true,
30        'cafile' => __DIR__ . '/bug54992-ca.pem',
31        'peer_name' => 'bug54992.local',
32    ]]);
33
34    phpt_wait();
35
36    stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT);
37    var_dump(stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx));
38
39    stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLS_CLIENT);
40    var_dump(stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx));
41CODE;
42
43include 'ServerClientTestCase.inc';
44ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
45?>
46--EXPECTF--
47resource(%d) of type (stream)
48resource(%d) of type (stream)
49