xref: /PHP-7.0/ext/openssl/tests/bug46127.phpt (revision 020e1619)
1--TEST--
2#46127, openssl_sign/verify: accept different algos
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 < 0x009070af) die("skip openssl version too low");
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__ . '/bug46127.pem',
15    ]]);
16
17    $sock = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
18    phpt_notify();
19
20    $link = stream_socket_accept($sock);
21    fwrite($link, "Sending bug 46127\n");
22CODE;
23
24$clientCode = <<<'CODE'
25    $serverUri = "ssl://127.0.0.1:64321";
26    $clientFlags = STREAM_CLIENT_CONNECT;
27
28    $clientCtx = stream_context_create(['ssl' => [
29        'verify_peer' => false,
30        'verify_peer_name' => false
31    ]]);
32
33    phpt_wait();
34    $sock = stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx);
35
36    echo fgets($sock);
37CODE;
38
39include 'ServerClientTestCase.inc';
40ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
41--EXPECT--
42Sending bug 46127
43