xref: /PHP-7.3/ext/openssl/tests/bug68265.phpt (revision b746e698)
1--TEST--
2Bug #68265: SAN match fails with trailing DNS dot
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__ . '/bug68265.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' => 'debs.ak-online.net',
31    ]]);
32
33    phpt_wait();
34
35    var_dump(stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx));
36CODE;
37
38include 'ServerClientTestCase.inc';
39ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
40?>
41--EXPECTF--
42resource(%d) of type (stream)
43