summaryrefslogtreecommitdiff
path: root/ext/openssl/tests/bug46127.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/tests/bug46127.phpt')
-rw-r--r--ext/openssl/tests/bug46127.phpt91
1 files changed, 35 insertions, 56 deletions
diff --git a/ext/openssl/tests/bug46127.phpt b/ext/openssl/tests/bug46127.phpt
index ef4a9be031..6a3d1a0d6c 100644
--- a/ext/openssl/tests/bug46127.phpt
+++ b/ext/openssl/tests/bug46127.phpt
@@ -2,62 +2,41 @@
#46127, openssl_sign/verify: accept different algos
--SKIPIF--
<?php
-if (!extension_loaded("openssl")) die("skip, openssl required");
-if (!extension_loaded("pcntl")) die("skip, pcntl required");
-if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
-?>
+if (!extension_loaded("openssl")) die("skip openssl not loaded");
+if (!function_exists("proc_open")) die("skip no proc_open");
+if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip openssl version too low");
--FILE--
<?php
-
-function ssl_server($port) {
- $pem = dirname(__FILE__) . '/bug46127.pem';
- $ssl = array(
- 'verify_peer' => false,
- 'verify_host' => false,
- 'allow_self_signed' => true,
- 'local_cert' => $pem,
- // 'passphrase' => '',
- );
- $context = stream_context_create(array('ssl' => $ssl));
- $sock = stream_socket_server('ssl://127.0.0.1:'.$port, $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context);
- if (!$sock) return false;
-
- $link = stream_socket_accept($sock);
- if (!$link) return false; // bad link?
-
- fputs($link, "Sending bug 46127\n");
-
- // close stuff
- fclose($link);
- fclose($sock);
-
- exit;
-}
-
-echo "Running bug46127\n";
-
-$port = rand(15000, 32000);
-
-$pid = pcntl_fork();
-if ($pid == 0) { // child
- ssl_server($port);
- exit;
-}
-
-// client or failed
-sleep(1);
-$ctx = stream_context_create(['ssl' => [
- 'verify_peer' => false,
- 'verify_host' => false
-]]);
-$sock = stream_socket_client("ssl://127.0.0.1:{$port}", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx);
-if (!$sock) exit;
-
-echo fgets($sock);
-
-pcntl_waitpid($pid, $status);
-
-?>
---EXPECTF--
-Running bug46127
+$serverCode = <<<'CODE'
+ $serverUri = "ssl://127.0.0.1:64321";
+ $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
+ $serverCtx = stream_context_create(['ssl' => [
+ 'local_cert' => __DIR__ . '/bug46127.pem',
+ ]]);
+
+ $sock = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
+ phpt_notify();
+
+ $link = stream_socket_accept($sock);
+ fwrite($link, "Sending bug 46127\n");
+CODE;
+
+$clientCode = <<<'CODE'
+ $serverUri = "ssl://127.0.0.1:64321";
+ $clientFlags = STREAM_CLIENT_CONNECT;
+
+ $clientCtx = stream_context_create(['ssl' => [
+ 'verify_peer' => false,
+ 'verify_host' => false
+ ]]);
+
+ phpt_wait();
+ $sock = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx);
+
+ echo fgets($sock);
+CODE;
+
+include 'ServerClientTestCase.inc';
+ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+--EXPECT--
Sending bug 46127