2013-10-05 03:55:29 +08:00
|
|
|
--TEST--
|
|
|
|
Specific crypto method for ssl:// transports.
|
|
|
|
--SKIPIF--
|
2014-02-15 04:39:02 +08:00
|
|
|
<?php
|
2014-02-24 22:55:17 +08:00
|
|
|
if (!extension_loaded("openssl")) die("skip openssl not loaded");
|
|
|
|
if (!function_exists("proc_open")) die("skip no proc_open");
|
2018-06-21 23:38:19 +08:00
|
|
|
?>
|
2013-10-05 03:55:29 +08:00
|
|
|
--FILE--
|
|
|
|
<?php
|
2014-02-24 22:55:17 +08:00
|
|
|
$serverCode = <<<'CODE'
|
|
|
|
$serverUri = "ssl://127.0.0.1:64321";
|
|
|
|
$serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
|
|
|
|
$serverCtx = stream_context_create(['ssl' => [
|
|
|
|
'local_cert' => __DIR__ . '/streams_crypto_method.pem',
|
|
|
|
]]);
|
2014-02-15 04:39:02 +08:00
|
|
|
|
2014-02-24 22:55:17 +08:00
|
|
|
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
|
|
|
|
phpt_notify();
|
2014-02-15 04:39:02 +08:00
|
|
|
|
2014-02-24 22:55:17 +08:00
|
|
|
$client = @stream_socket_accept($server);
|
|
|
|
if ($client) {
|
|
|
|
$in = '';
|
|
|
|
while (!preg_match('/\r?\n\r?\n/', $in)) {
|
|
|
|
$in .= fread($client, 2048);
|
|
|
|
}
|
|
|
|
$response = "HTTP/1.0 200 OK\r\n"
|
|
|
|
. "Content-Type: text/plain\r\n"
|
|
|
|
. "Content-Length: 12\r\n"
|
|
|
|
. "Connection: close\r\n"
|
|
|
|
. "\r\n"
|
|
|
|
. "Hello World!";
|
|
|
|
fwrite($client, $response);
|
|
|
|
fclose($client);
|
|
|
|
}
|
|
|
|
CODE;
|
2014-02-15 06:17:30 +08:00
|
|
|
|
2014-02-24 22:55:17 +08:00
|
|
|
$clientCode = <<<'CODE'
|
|
|
|
$serverUri = "https://127.0.0.1:64321/";
|
|
|
|
$clientFlags = STREAM_CLIENT_CONNECT;
|
|
|
|
$clientCtx = stream_context_create(['ssl' => [
|
2015-04-09 00:55:55 +08:00
|
|
|
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
|
2014-02-24 22:55:17 +08:00
|
|
|
'verify_peer' => false,
|
2014-02-27 04:06:08 +08:00
|
|
|
'verify_peer_name' => false
|
2014-02-24 22:55:17 +08:00
|
|
|
]]);
|
2014-02-15 06:17:30 +08:00
|
|
|
|
2014-02-24 22:55:17 +08:00
|
|
|
phpt_wait();
|
|
|
|
echo file_get_contents($serverUri, false, $clientCtx);
|
|
|
|
CODE;
|
2013-10-05 03:55:29 +08:00
|
|
|
|
2014-02-24 22:55:17 +08:00
|
|
|
include 'ServerClientTestCase.inc';
|
|
|
|
ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
|
2018-06-21 23:38:19 +08:00
|
|
|
?>
|
2018-02-19 16:59:41 +08:00
|
|
|
--EXPECT--
|
2013-10-05 03:55:29 +08:00
|
|
|
Hello World!
|