1--TEST--
2Verify host name by default in client transfers
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_001.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$peerName = 'stream_verify_peer_name_001';
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' => false,
33        'peer_name' => '%s'
34    ]]);
35
36    phpt_wait();
37    $client = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx);
38
39    var_dump($client);
40CODE;
41$clientCode = sprintf($clientCode, $peerName);
42
43include 'CertificateGenerator.inc';
44$certificateGenerator = new CertificateGenerator();
45$certificateGenerator->saveNewCertAsFileWithKey($peerName, $certFile);
46
47include 'ServerClientTestCase.inc';
48ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
49?>
50--CLEAN--
51<?php
52@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'stream_verify_peer_name_001.pem.tmp');
53?>
54--EXPECTF--
55resource(%d) of type (stream)
56