Annotation of embedaddon/php/ext/openssl/tests/bug46127.phpt, revision 1.1

1.1     ! misho       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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>