Bug #69319 [NEW]: stream_context_set_default() options not set as default in streaming functions
| From: | php at 281180 dot de | Date: | Sat, 28 Mar 2015 12:52:27 +0000 |
| Subject: | Bug #69319 [NEW]: stream_context_set_default() options not set as default in streaming functions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191661@lists.php.net to get a copy of this message | ||
From: php at 281180 dot de
Operating system: Linux Debian Wheezy 7.8
PHP version: 5.6.7
Package: Streams related
Bug Type: Bug
Bug description:stream_context_set_default() options not set as default in streaming functions
Description:
------------
As of PHP 5.6 all encrypted client streams now enable peer verification
by default.
The problem is that e. g. some certs are self-signed and streams will
not work without adjusting some parts.
The easiest way in some cases would be enabling the ssl option
'allow_self_signed' via stream_context_set_default()
But unfortunately options set via stream_context_set_default() are not
honored by e. g. stream_socket_client()
Other packages seem to have the same problem:
- #54440 (here an XML issue)
- #68344 (here a MySQL issue)
Test script:
---------------
// set default stream options
$default_options = [
'ssl' => [
'allow_self_signed' => true,
],
];
stream_context_set_default($default_options);
// set special stream options
$options = [
'ssl' => [
'verify_peer_name' => false,
],
];
// open stream considering default options
$stream = stream_socket_client($host.':'.$port, $errno, $errstr,
$timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
Expected result:
----------------
Stream to work and honor both $default_options and $options
Actual result:
--------------
$default_options are ignored and the following warning is triggered:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL
Error messages: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in XXX on
line XX
--
Edit bug report at https://bugs.php.net/bug.php?id=69319&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69319&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69319&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69319&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69319&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69319&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69319&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69319&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69319&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69319&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69319&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69319&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69319&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69319&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69319&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69319&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69319&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69319&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69319&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69319&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69319&r=mysqlcfg