Annotation of embedaddon/php/ext/openssl/tests/bug54992.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Bug #54992: Stream not closed and error not returned when SSL CN_match fails
                      3: --SKIPIF--
                      4: <?php 
                      5: if (!extension_loaded("openssl")) die("skip");
                      6: if (!function_exists('pcntl_fork')) die("skip no fork");
                      7: --FILE--
                      8: <?php
                      9: $context = stream_context_create();
                     10: 
                     11: stream_context_set_option($context, 'ssl', 'local_cert', __DIR__ . "/bug54992.pem");
                     12: stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
                     13: $server = stream_socket_server('ssl://127.0.0.1:64321', $errno, $errstr,
                     14:        STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
                     15: 
                     16: 
                     17: $pid = pcntl_fork();
                     18: if ($pid == -1) {
                     19:        die('could not fork');
                     20: } else if ($pid) {
                     21:        $contextC = stream_context_create(
                     22:                array(
                     23:                        'ssl' => array(
                     24:                                'verify_peer'           => true,
                     25:                                'cafile'                => __DIR__ . '/bug54992-ca.pem',
                     26:                                'CN_match'              => 'buga_buga',
                     27:                        )
                     28:                )
                     29:        );
                     30:        var_dump(stream_socket_client("ssl://127.0.0.1:64321", $errno, $errstr, 1,
                     31:                STREAM_CLIENT_CONNECT, $contextC));
                     32: } else {       
                     33:        @pcntl_wait($status);
                     34:        @stream_socket_accept($server, 1);
                     35: }
                     36: --EXPECTF--
                     37: Warning: stream_socket_client(): Peer certificate CN=`bug54992.local' did not match expected CN=`buga_buga' in %s on line %d
                     38: 
                     39: Warning: stream_socket_client(): Failed to enable crypto in %s on line %d
                     40: 
                     41: Warning: stream_socket_client(): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in %s on line %d
                     42: bool(false)
                     43: 
                     44: 

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