~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/openssl/tests/bug46127.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
#46127, openssl_sign/verify: accept different algos 
 
3
--SKIPIF--
 
4
<?php 
 
5
if (!extension_loaded("openssl")) die("skip, openssl required");
 
6
if (!extension_loaded("pcntl")) die("skip, pcntl required");
 
7
if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
 
8
?>
 
9
--FILE--
 
10
<?php
 
11
 
 
12
function 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
 
 
36
echo "Running bug46127\n";
 
37
 
 
38
$port = rand(15000, 32000);
 
39
 
 
40
$pid = pcntl_fork();
 
41
if ($pid == 0) { // child
 
42
        ssl_server($port);
 
43
        exit;
 
44
}
 
45
 
 
46
// client or failed
 
47
sleep(1);
 
48
$sock = fsockopen('ssl://127.0.0.1', $port, $errno, $errstr);
 
49
if (!$sock) exit;
 
50
 
 
51
echo fgets($sock);
 
52
 
 
53
pcntl_waitpid($pid, $status);
 
54
 
 
55
?>
 
56
--EXPECTF--
 
57
Running bug46127
 
58
Sending bug 46127