From: Daniel Lowrey Date: Fri, 14 Feb 2014 20:39:02 +0000 (-0700) Subject: Fix test broken if openssl is compiled without sslv2 X-Git-Tag: php-5.6.0alpha3~1^2~94 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f073588e7529ea12d3023369ddad78167b00e31b;p=php Fix test broken if openssl is compiled without sslv2 --- diff --git a/ext/openssl/tests/streams_crypto_method.phpt b/ext/openssl/tests/streams_crypto_method.phpt index 981f56b399..b7b8e257b4 100644 --- a/ext/openssl/tests/streams_crypto_method.phpt +++ b/ext/openssl/tests/streams_crypto_method.phpt @@ -1,42 +1,48 @@ --TEST-- Specific crypto method for ssl:// transports. --SKIPIF-- - --FILE-- [ + 'local_cert' => dirname(__FILE__) . '/streams_crypto_method.pem', + 'allow_self_signed' => true, + 'verify_peer' => false +]]); +$serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; +$server = stream_socket_server('sslv3://127.0.0.1:12345', $errno, $errstr, $serverFlags, $serverCtx); + +$pid = pcntl_fork(); + +if ($pid == -1) { + die('could not fork'); +} else if ($pid) { + $clientCtx = stream_context_create(['ssl' => [ + 'crypto_method' => STREAM_CRYPTO_METHOD_SSLv3_CLIENT, + 'verify_peer' => false + ]]); + + $fp = fopen('https://127.0.0.1:12345/', 'r', false, $clientCtx); + + if ($fp) { + fpassthru($fp); + fclose($fp); + } +} else { + @pcntl_wait($status); + + $client = @stream_socket_accept($server); + + if ($client) { + $in = ''; + while (!preg_match('/\r?\n\r?\n/', $in)) { + $in .= fread($client, 2048); + } + + $response = << --EXPECTF-- Hello World! +