forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bug-47030' of https://github.com/rdlowrey/php-src into …
…PHP-5.6 * 'bug-47030' of https://github.com/rdlowrey/php-src: Bug #47030 (separate host and peer verification)
- Loading branch information
Showing
10 changed files
with
223 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--TEST-- | ||
Verify host name by default in client transfers | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("openssl")) die("skip"); | ||
if (!function_exists('pcntl_fork')) die("skip no fork"); | ||
--FILE-- | ||
<?php | ||
$serverUri = "ssl://127.0.0.1:64321"; | ||
$serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; | ||
$serverCtx = stream_context_create(['ssl' => [ | ||
'local_cert' => __DIR__ . '/bug54992.pem' | ||
]]); | ||
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); | ||
|
||
$pid = pcntl_fork(); | ||
if ($pid == -1) { | ||
die('could not fork'); | ||
} else if ($pid) { | ||
|
||
$clientFlags = STREAM_CLIENT_CONNECT; | ||
$clientCtx = stream_context_create(['ssl' => [ | ||
'verify_peer' => false, | ||
'CN_match' => 'bug54992.local' | ||
]]); | ||
|
||
$client = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); | ||
var_dump($client); | ||
|
||
} else { | ||
@pcntl_wait($status); | ||
@stream_socket_accept($server, 1); | ||
} | ||
--EXPECTF-- | ||
resource(%d) of type (stream) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--TEST-- | ||
Allow host name mismatch when "verify_host" disabled | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("openssl")) die("skip"); | ||
if (!function_exists('pcntl_fork')) die("skip no fork"); | ||
--FILE-- | ||
<?php | ||
$serverUri = "ssl://127.0.0.1:64321"; | ||
$serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; | ||
$serverCtx = stream_context_create(['ssl' => [ | ||
'local_cert' => __DIR__ . '/bug54992.pem' | ||
]]); | ||
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); | ||
|
||
$pid = pcntl_fork(); | ||
if ($pid == -1) { | ||
die('could not fork'); | ||
} else if ($pid) { | ||
|
||
$clientFlags = STREAM_CLIENT_CONNECT; | ||
$clientCtx = stream_context_create(['ssl' => [ | ||
'verify_peer' => true, | ||
'cafile' => __DIR__ . '/bug54992-ca.pem', | ||
'verify_host' => false | ||
]]); | ||
|
||
$client = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); | ||
var_dump($client); | ||
|
||
} else { | ||
@pcntl_wait($status); | ||
@stream_socket_accept($server, 1); | ||
} | ||
--EXPECTF-- | ||
resource(%d) of type (stream) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--TEST-- | ||
Host name mismatch triggers error | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("openssl")) die("skip"); | ||
if (!function_exists('pcntl_fork')) die("skip no fork"); | ||
--FILE-- | ||
<?php | ||
$serverUri = "ssl://127.0.0.1:64321"; | ||
$serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; | ||
$serverCtx = stream_context_create(['ssl' => [ | ||
'local_cert' => __DIR__ . '/bug54992.pem' | ||
]]); | ||
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); | ||
|
||
$pid = pcntl_fork(); | ||
if ($pid == -1) { | ||
die('could not fork'); | ||
} else if ($pid) { | ||
|
||
$clientFlags = STREAM_CLIENT_CONNECT; | ||
$clientCtx = stream_context_create(['ssl' => [ | ||
'verify_peer' => true, | ||
'cafile' => __DIR__ . '/bug54992-ca.pem' | ||
]]); | ||
|
||
$client = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); | ||
var_dump($client); | ||
|
||
} else { | ||
@pcntl_wait($status); | ||
@stream_socket_accept($server, 1); | ||
} | ||
--EXPECTF-- | ||
Warning: stream_socket_client(): Peer certificate CN=`bug54992.local' did not match expected CN=`127.0.0.1' 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) |
Oops, something went wrong.