PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/openssl/tests/bug54992.phpt ('Bug #54992: Stream not closed and error not returned when SSL CN_match fails')

Script

1: <?php
2: $certFile 
__DIR__ DIRECTORY_SEPARATOR 'bug54992.pem.tmp';
3:
$cacertFile __DIR__ DIRECTORY_SEPARATOR 'bug54992-ca.pem.tmp';
4:
5:
$serverCode = <<<'CODE'
6:
    $serverUri = "ssl://127.0.0.1:64321";
7:     $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
8:     $serverCtx = stream_context_create(['ssl' => [
9:         'local_cert' => '%s',
10:     ]]);
11:
12:     $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
13:     phpt_notify();
14:
15:     @stream_socket_accept($server, 1);
16:
CODE;
17:
$serverCode sprintf($serverCode$certFile);
18:
19:
$peerName 'bug54992_actual_peer_name';
20:
$wrongPeerName 'bug54992_expected_peer_name';
21:
$clientCode = <<<'CODE'
22:
    $serverUri = "ssl://127.0.0.1:64321";
23:     $clientFlags = STREAM_CLIENT_CONNECT;
24:     $clientCtx = stream_context_create(['ssl' => [
25:         'verify_peer' => true,
26:         'cafile' => '%s',
27:         'peer_name' => '%s',
28:     ]]);
29:
30:     phpt_wait();
31:     $client = stream_socket_client($serverUri, $errno, $errstr, 2, $clientFlags, $clientCtx);
32:
33:     var_dump($client);
34:
CODE;
35:
$clientCode sprintf($clientCode$cacertFile$wrongPeerName);
36:
37: include 
'CertificateGenerator.inc';
38:
$certificateGenerator = new CertificateGenerator();
39:
$certificateGenerator->saveCaCert($cacertFile);
40:
$certificateGenerator->saveNewCertAsFileWithKey($peerName$certFile);
41:
42: include 
'ServerClientTestCase.inc';
43:
ServerClientTestCase::getInstance()->run($clientCode$serverCode);
44:
?>
45:

Expected

Warning: stream_socket_client(): Peer certificate CN=`bug54992_actual_peer_name' did not match expected CN=`bug54992_expected_peer_name' in %s on line %d

Warning: stream_socket_client(): Failed to enable crypto in %s on line %d

Warning: stream_socket_client(): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in %s on line %d
bool(false)

Output

Warning: stream_socket_client(): SSL: Handshake timed out in /var/php_gcov/PHP_HEAD/ext/openssl/tests/ServerClientTestCase.inc(96) : eval()'d code on line 10

Warning: stream_socket_client(): Failed to enable crypto in /var/php_gcov/PHP_HEAD/ext/openssl/tests/ServerClientTestCase.inc(96) : eval()'d code on line 10

Warning: stream_socket_client(): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in /var/php_gcov/PHP_HEAD/ext/openssl/tests/ServerClientTestCase.inc(96) : eval()'d code on line 10
bool(false)

Diff

001+ Warning: stream_socket_client(): SSL: Handshake timed out in /var/php_gcov/PHP_HEAD/ext/openssl/tests/ServerClientTestCase.inc(96) : eval()'d code on line 10
001- Warning: stream_socket_client(): Peer certificate CN=`bug54992_actual_peer_name' did not match expected CN=`bug54992_expected_peer_name' in %s on line %d

 

Generated at Mon, 14 Jan 2019 03:56:25 +0000 (4 days ago)

Copyright © 2005-2019 The PHP Group
All rights reserved.