xref: /PHP-5.5/ext/openssl/tests/bug46127.phpt (revision d316c3e0)
1--TEST--
2#46127, openssl_sign/verify: accept different algos
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl")) die("skip, openssl required");
6if (!extension_loaded("pcntl")) die("skip, pcntl required");
7if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
8?>
9--FILE--
10<?php
11
12function ssl_server($port) {
13	$pem = dirname(__FILE__) . '/bug46127.pem';
14	$ssl = array(
15			'verify_peer' => false,
16			'allow_self_signed' => true,
17			'local_cert' => $pem,
18			//		'passphrase' => '',
19		    );
20	$context = stream_context_create(array('ssl' => $ssl));
21	$sock = stream_socket_server('ssl://127.0.0.1:'.$port, $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context);
22	if (!$sock) return false;
23
24	$link = stream_socket_accept($sock);
25	if (!$link) return false; // bad link?
26
27	fputs($link, "Sending bug 46127\n");
28
29	// close stuff
30	fclose($link);
31	fclose($sock);
32
33	exit;
34}
35
36echo "Running bug46127\n";
37
38$port = rand(15000, 32000);
39
40$pid = pcntl_fork();
41if ($pid == 0) { // child
42	ssl_server($port);
43	exit;
44}
45
46// client or failed
47sleep(1);
48$sock = fsockopen('ssl://127.0.0.1', $port, $errno, $errstr);
49if (!$sock) exit;
50
51echo fgets($sock);
52
53pcntl_waitpid($pid, $status);
54
55?>
56--EXPECTF--
57Running bug46127
58Sending bug 46127
59