1--TEST--
2Allow host name mismatch when "verify_host" disabled
3--EXTENSIONS--
4openssl
5--SKIPIF--
6<?php
7if (!function_exists("proc_open")) die("skip no proc_open");
8?>
9--FILE--
10<?php
11$certFile = __DIR__ . DIRECTORY_SEPARATOR . 'stream_verify_peer_name_002.pem.tmp';
12$cacertFile = __DIR__ . DIRECTORY_SEPARATOR . 'stream_verify_peer_name_002-ca.pem.tmp';
13
14$serverCode = <<<'CODE'
15    $serverUri = "ssl://127.0.0.1:64321";
16    $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
17    $serverCtx = stream_context_create(['ssl' => [
18        'local_cert' => '%s'
19    ]]);
20
21    $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
22    phpt_notify();
23
24    @stream_socket_accept($server, 1);
25CODE;
26$serverCode = sprintf($serverCode, $certFile);
27
28$actualPeerName = 'stream_verify_peer_name_002';
29$clientCode = <<<'CODE'
30    $serverUri = "ssl://127.0.0.1:64321";
31    $clientFlags = STREAM_CLIENT_CONNECT;
32    $clientCtx = stream_context_create(['ssl' => [
33        'verify_peer' => true,
34        'cafile' => '%s',
35        'verify_peer_name' => false
36    ]]);
37
38    phpt_wait();
39    $client = stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx);
40
41    var_dump($client);
42CODE;
43$clientCode = sprintf($clientCode, $cacertFile);
44
45include 'CertificateGenerator.inc';
46$certificateGenerator = new CertificateGenerator();
47$certificateGenerator->saveCaCert($cacertFile);
48$certificateGenerator->saveNewCertAsFileWithKey($actualPeerName, $certFile);
49
50include 'ServerClientTestCase.inc';
51ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
52?>
53--CLEAN--
54<?php
55@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'stream_verify_peer_name_002.pem.tmp');
56@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'stream_verify_peer_name_002-ca.pem.tmp');
57?>
58--EXPECTF--
59resource(%d) of type (stream)
60