xref: /PHP-7.3/ext/openssl/tests/bug69215.phpt (revision b746e698)
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?>
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__ . '/bug69215-server.pem',
15        'passphrase' => 'elephpant',
16        'cafile' => __DIR__ . '/bug69215-ca.pem',
17        'verify_peer' => true,
18        'verify_peer_name' => true,
19        'peer_name' => 'bug69215-client',
20    ]]);
21
22    $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
23    phpt_notify();
24
25    stream_socket_accept($server, 30);
26CODE;
27
28$clientCode = <<<'CODE'
29    $serverUri = "ssl://127.0.0.1:64321";
30    $clientFlags = STREAM_CLIENT_CONNECT;
31    $clientCtx = stream_context_create(['ssl' => [
32        'local_cert' => __DIR__ . '/bug69215-client.pem',
33        'passphrase' => 'elephpant',
34        'cafile' => __DIR__ . '/bug69215-ca.pem',
35        'verify_peer' => true,
36        'verify_peer_name' => true,
37        'peer_name' => 'bug69215-server',
38    ]]);
39
40    phpt_wait();
41
42    var_dump(stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx));
43CODE;
44
45include 'ServerClientTestCase.inc';
46ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
47?>
48--EXPECTF--
49resource(%d) of type (stream)
50