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
|
2013-10-05 03:55:29 +08:00
|
|
|
if (!extension_loaded('openssl')) die('skip, openssl required');
|
|
|
|
if (!extension_loaded('pcntl')) die('skip, pcntl required');
|
|
|
|
?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
2014-02-15 04:39:02 +08:00
|
|
|
$serverCtx = stream_context_create(['ssl' => [
|
|
|
|
'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 = <<<EOS
|
2013-10-05 03:55:29 +08:00
|
|
|
HTTP/1.1 200 OK
|
|
|
|
Content-Type: text/plain
|
|
|
|
Content-Length: 13
|
|
|
|
Connection: close
|
|
|
|
|
|
|
|
Hello World!
|
|
|
|
|
|
|
|
EOS;
|
2014-02-15 04:39:02 +08:00
|
|
|
fwrite($client, $response);
|
|
|
|
fclose($client);
|
2013-10-05 03:55:29 +08:00
|
|
|
|
2014-02-15 04:39:02 +08:00
|
|
|
exit();
|
|
|
|
}
|
2013-10-05 03:55:29 +08:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
Hello World!
|
2014-02-15 04:39:02 +08:00
|
|
|
|