Skip to content

Commit 674dd73

Browse files
committed
Added two more test cases for CN matching.
1 parent a820c3d commit 674dd73

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

ext/openssl/tests/bug65729.phpt

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,28 @@ stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
1313
$server = stream_socket_server('ssl://127.0.0.1:64321', $errno, $errstr,
1414
STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
1515

16+
$expected_names = array('foo.test.com.sg', 'foo.test.com', 'foo.bar.test.com');
17+
1618
$pid = pcntl_fork();
1719
if ($pid == -1) {
1820
die('could not fork');
1921
} else if ($pid) {
20-
$contextC = stream_context_create(
21-
array(
22+
foreach ($expected_names as $expected_name) {
23+
$contextC = stream_context_create(array(
2224
'ssl' => array(
2325
'verify_peer' => true,
2426
'allow_self_signed' => true,
25-
'CN_match' => 'foo.test.com.sg',
27+
'CN_match' => $expected_name,
2628
)
27-
)
28-
);
29-
var_dump(stream_socket_client("ssl://127.0.0.1:64321", $errno, $errstr, 1,
29+
));
30+
var_dump(stream_socket_client("ssl://127.0.0.1:64321", $errno, $errstr, 1,
3031
STREAM_CLIENT_CONNECT, $contextC));
32+
}
3133
} else {
3234
@pcntl_wait($status);
33-
@stream_socket_accept($server, 1);
35+
foreach ($expected_names as $name) {
36+
@stream_socket_accept($server, 1);
37+
}
3438
}
3539
--EXPECTF--
3640
Warning: stream_socket_client(): Peer certificate CN=`*.test.com' did not match expected CN=`foo.test.com.sg' in %s on line %d
@@ -39,4 +43,11 @@ Warning: stream_socket_client(): Failed to enable crypto in %s on line %d
3943

4044
Warning: stream_socket_client(): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in %s on line %d
4145
bool(false)
46+
resource(%d) of type (stream)
47+
48+
Warning: stream_socket_client(): Peer certificate CN=`*.test.com' did not match expected CN=`foo.bar.test.com' in %s on line %d
49+
50+
Warning: stream_socket_client(): Failed to enable crypto in %s on line %d
4251

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

0 commit comments

Comments
 (0)