1--TEST-- 2Specific crypto method for ssl:// transports. 3--SKIPIF-- 4<?php 5if (!extension_loaded("openssl")) die("skip openssl not loaded"); 6if (!function_exists("proc_open")) die("skip no proc_open"); 7if (OPENSSL_VERSION_NUMBER < 0x10001001) die("skip OpenSSLv1.0.1 required"); 8--FILE-- 9<?php 10$serverCode = <<<'CODE' 11 $serverUri = "ssl://127.0.0.1:64321"; 12 $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; 13 $serverCtx = stream_context_create(['ssl' => [ 14 'local_cert' => __DIR__ . '/streams_crypto_method.pem', 15 ]]); 16 17 $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); 18 phpt_notify(); 19 20 $client = @stream_socket_accept($server); 21 if ($client) { 22 $in = ''; 23 while (!preg_match('/\r?\n\r?\n/', $in)) { 24 $in .= fread($client, 2048); 25 } 26 $response = "HTTP/1.0 200 OK\r\n" 27 . "Content-Type: text/plain\r\n" 28 . "Content-Length: 12\r\n" 29 . "Connection: close\r\n" 30 . "\r\n" 31 . "Hello World!"; 32 fwrite($client, $response); 33 fclose($client); 34 } 35CODE; 36 37$clientCode = <<<'CODE' 38 $serverUri = "https://127.0.0.1:64321/"; 39 $clientFlags = STREAM_CLIENT_CONNECT; 40 $clientCtx = stream_context_create(['ssl' => [ 41 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, 42 'verify_peer' => false, 43 'verify_peer_name' => false 44 ]]); 45 46 phpt_wait(); 47 echo file_get_contents($serverUri, false, $clientCtx); 48CODE; 49 50include 'ServerClientTestCase.inc'; 51ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 52--EXPECTF-- 53Hello World! 54