xref: /PHP-7.0/ext/openssl/tests/bug69215.phpt (revision 3f6b1279)
1--TEST--
2Bug #69215: Crypto servers should send client CA list
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl")) die("skip openssl not loaded");
6if (!function_exists("proc_open")) die("skip no proc_open");
7--FILE--
8<?php
9$serverCode = <<<'CODE'
10    $serverUri = "ssl://127.0.0.1:64321";
11    $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
12    $serverCtx = stream_context_create(['ssl' => [
13        'local_cert' => __DIR__ . '/bug69215-server.pem',
14        'passphrase' => 'elephpant',
15        'cafile' => __DIR__ . '/bug69215-ca.pem',
16        'verify_peer' => true,
17        'verify_peer_name' => true,
18        'peer_name' => 'bug69215-client',
19    ]]);
20
21    $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
22    phpt_notify();
23
24    stream_socket_accept($server, 30);
25CODE;
26
27$clientCode = <<<'CODE'
28    $serverUri = "ssl://127.0.0.1:64321";
29    $clientFlags = STREAM_CLIENT_CONNECT;
30    $clientCtx = stream_context_create(['ssl' => [
31        'local_cert' => __DIR__ . '/bug69215-client.pem',
32        'passphrase' => 'elephpant',
33        'cafile' => __DIR__ . '/bug69215-ca.pem',
34        'verify_peer' => true,
35        'verify_peer_name' => true,
36        'peer_name' => 'bug69215-server',
37    ]]);
38
39    phpt_wait();
40
41    var_dump(stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx));
42CODE;
43
44include 'ServerClientTestCase.inc';
45ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
46--EXPECTF--
47resource(%d) of type (stream)
48
49