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