Bug #74796 [NEW]: Requests through https:// with http proxy set altering default context

From: Date: Thu, 22 Jun 2017 11:06:36 +0000
Subject: Bug #74796 [NEW]: Requests through https:// with http proxy set altering default context
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209625@lists.php.net to get a copy of this message
From: anrdaemon at freemail dot ru Operating system: Windows, Linux PHP version: 7.1.6 Package: Streams related Bug Type: Bug Bug description:Requests through https:// with http proxy set altering default context Description: ------------ Adding http proxy to default stream context making addressing different HTTPS domains in the same script impossible. First request to HTTPS site after associating a http proxy sets ssl context to a single peer name and requests to any other domain will fail. Tested with 7.1.6 and 5.6.30 on Windows and Ubuntu Linux. Test script: --------------- <?php stream_context_set_default([ "https" => [ "proxy" => "tcp://proxy:3128" ], ]); var_dump(stream_context_get_options(stream_context_get_default())); file_get_contents("https://www.google.com/"); // fine var_dump(stream_context_get_options(stream_context_get_default())); file_get_contents("https://www.yahoo.com/"); // fine var_dump(stream_context_get_options(stream_context_get_default())); stream_context_set_default([ "http" => [ "proxy" => "tcp://proxy:3128" ], ]); var_dump(stream_context_get_options(stream_context_get_default())); file_get_contents("https://www.google.com/"); // fine var_dump(stream_context_get_options(stream_context_get_default())); // ssl:peer_name is set file_get_contents("https://www.yahoo.com/"); // Peer certificate CN=*.www.yahoo.com' did not match expected CN=www.google.com' in ... var_dump(stream_context_get_options(stream_context_get_default())); Expected result: ---------------- array(1) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(1) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(1) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(2) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } ["http"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(3) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } ["http"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(3) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } ["http"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } Actual result: -------------- array(1) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(1) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(1) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(2) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } ["http"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } } array(3) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } ["http"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } ["ssl"]=> array(1) { ["peer_name"]=> string(14) "www.google.com" } } PHP Warning: file_get_contents(): Peer certificate CN=`*.www.yahoo.com' did not match expected CN=`www.google.com' in test.php on line 21 PHP Warning: file_get_contents(https://www.yahoo.com/): failed to open stream: Cannot connect to HTTPS server through proxy in test.php on line 21 array(3) { ["https"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } ["http"]=> array(1) { ["proxy"]=> string(16) "tcp://proxy:3128" } ["ssl"]=> array(1) { ["peer_name"]=> string(14) "www.google.com" } } -- Edit bug report at https://bugs.php.net/bug.php?id=74796&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74796&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74796&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74796&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74796&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74796&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74796&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74796&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74796&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74796&r=support Expected behavior: https://bugs.php.net/fix.php?id=74796&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74796&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74796&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74796&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74796&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74796&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74796&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74796&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74796&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74796&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74796&r=mysqlcfg

« previous php.bugs (#209625) next »