xref: /PHP-7.2/ext/openssl/tests/bug68879.phpt (revision f1d7e3ca)
1--TEST--
2Bug #68879: Match IP address fields in subjectAltName checks
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__ . '/bug68879.pem',
15        'passphrase' => 'elephpant',
16    ]]);
17
18    $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
19    phpt_notify();
20
21    stream_socket_accept($server, 30);
22CODE;
23
24$clientCode = <<<'CODE'
25    $serverUri = "ssl://127.0.0.1:64321";
26    $clientFlags = STREAM_CLIENT_CONNECT;
27    $clientCtx = stream_context_create(['ssl' => [
28        'verify_peer' => false,
29        'verify_peer_name' => true,
30        'peer_name' => '10.2.0.1',
31    ]]);
32
33    phpt_wait();
34
35    var_dump(stream_socket_client($serverUri, $errno, $errstr, 30, $clientFlags, $clientCtx));
36CODE;
37
38include 'ServerClientTestCase.inc';
39ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
40?>
41--EXPECTF--
42resource(%d) of type (stream)
43