@@ -13,24 +13,28 @@ stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
13
13
$ server = stream_socket_server ('ssl://127.0.0.1:64321 ' , $ errno , $ errstr ,
14
14
STREAM_SERVER_BIND |STREAM_SERVER_LISTEN , $ context );
15
15
16
+ $ expected_names = array ('foo.test.com.sg ' , 'foo.test.com ' , 'foo.bar.test.com ' );
17
+
16
18
$ pid = pcntl_fork ();
17
19
if ($ pid == -1 ) {
18
20
die ('could not fork ' );
19
21
} else if ($ pid ) {
20
- $ contextC = stream_context_create (
21
- array (
22
+ foreach ( $ expected_names as $ expected_name ) {
23
+ $ contextC = stream_context_create ( array (
22
24
'ssl ' => array (
23
25
'verify_peer ' => true ,
24
26
'allow_self_signed ' => true ,
25
- 'CN_match ' => ' foo.test.com.sg ' ,
27
+ 'CN_match ' => $ expected_name ,
26
28
)
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 ,
30
31
STREAM_CLIENT_CONNECT , $ contextC ));
32
+ }
31
33
} else {
32
34
@pcntl_wait ($ status );
33
- @stream_socket_accept ($ server , 1 );
35
+ foreach ($ expected_names as $ name ) {
36
+ @stream_socket_accept ($ server , 1 );
37
+ }
34
38
}
35
39
--EXPECTF --
36
40
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
39
43
40
44
Warning: stream_socket_client (): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in %s on line %d
41
45
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
42
51
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