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