1--TEST-- 2Host name mismatch triggers error 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__ . '/bug54992.pem' 14 ]]); 15 16 $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); 17 phpt_notify(); 18 19 @stream_socket_accept($server, 1); 20CODE; 21 22$clientCode = <<<'CODE' 23 $serverUri = "ssl://127.0.0.1:64321"; 24 $clientFlags = STREAM_CLIENT_CONNECT; 25 $clientCtx = stream_context_create(['ssl' => [ 26 'verify_peer' => true, 27 'cafile' => __DIR__ . '/bug54992-ca.pem' 28 ]]); 29 30 phpt_wait(); 31 $client = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); 32 33 var_dump($client); 34CODE; 35 36include 'ServerClientTestCase.inc'; 37ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 38--EXPECTF-- 39Warning: stream_socket_client(): Peer certificate CN=`bug54992.local' did not match expected CN=`127.0.0.1' in %s on line %d 40 41Warning: stream_socket_client(): Failed to enable crypto in %s on line %d 42 43Warning: stream_socket_client(): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in %s on line %d 44bool(false) 45