1--TEST-- 2Bug #68879: Match IP address fields in subjectAltName checks 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 . 'bug68879.pem.tmp'; 12$san = 'DNS:test.com, DNS:www.test.com, DNS:subdomain.test.com, IP:0:0:0:0:0:FFFF:A02:1, IP:10.2.0.1'; 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, 30); 25CODE; 26$serverCode = sprintf($serverCode, $certFile); 27 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 'verify_peer_name' => true, 34 'peer_name' => '10.2.0.1', 35 ]]); 36 37 phpt_wait(); 38 39 var_dump(stream_socket_client($serverUri, $errno, $errstr, 30, $clientFlags, $clientCtx)); 40CODE; 41 42include 'CertificateGenerator.inc'; 43$certificateGenerator = new CertificateGenerator(); 44$certificateGenerator->saveNewCertAsFileWithKey('test.com', $certFile, null, $san); 45 46include 'ServerClientTestCase.inc'; 47ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 48?> 49--CLEAN-- 50<?php 51@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'bug68879.pem.tmp'); 52?> 53--EXPECTF-- 54resource(%d) of type (stream) 55