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