php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80851 https doesn't respect stream context option http.timeout -1
Submitted: 2021-03-10 12:56 UTC Modified: 2021-03-11 10:22 UTC
From: athorcis at yahoo dot fr Assigned:
Status: Not a bug Package: HTTP related
PHP Version: Irrelevant OS: ALL
Private report: No CVE-ID: None
 [2021-03-10 12:56 UTC] athorcis at yahoo dot fr
Description:
------------
When trying to access an HTTPS URL through streams if the HTTP timeout is set to a negative value then the function fails with the following warnings: 
Warning: file_get_contents(): SSL: Handshake timed out in Command line code on line 1
Warning: file_get_contents(): Failed to enable crypto in Command line code on line 1
Warning: file_get_contents(https://www.google.fr/): failed to open stream: operation failed in Command line code on line 1

I reproduced the error on Debian but also on Windows using these versions: 5.4, 5.5, 5.6 and 7.4

Test script:
---------------
file_get_contents('https://www.google.fr/', false, stream_context_create(['http' => ['timeout' => -1]]));

Expected result:
----------------
The options http.timeout -1 si suppose to prevent timeout errors not cause them

Actual result:
--------------
The options http.timeout -1 cause an a timeout error with https streams

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-10 14:26 UTC] cmb@php.net
I cannot reproduce this on Windows with PHP-7.4.

> The options http.timeout -1 si suppose to prevent timeout errors
> not cause them

While this apparently a valid assumption[1], it is not documented
in the PHP manual.

[1] <https://github.com/php/php-src/blob/php-7.4.16/ext/openssl/xp_ssl.c#L1955>
 [2021-03-10 14:51 UTC] athorcis at yahoo dot fr
It is not documented directly but http.timeout uses default_socket_timeout as a default value and default_socket_timeout allow negative values as specified here https://www.php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout
 [2021-03-10 15:15 UTC] athorcis at yahoo dot fr
my bad, the bug was fixed last summer but I was testing with PHP-7.4.6 which is why I experienced the problem (https://github.com/php/php-src/commit/eadd98070662f0c56d7138bcb2a42d397c11f6e4)
 [2021-03-10 15:17 UTC] athorcis at yahoo dot fr
-Status: Open +Status: Closed
 [2021-03-10 15:17 UTC] athorcis at yahoo dot fr
-
 [2021-03-11 10:22 UTC] cmb@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Aug 01 15:01:24 2021 UTC