Skip to content

Warning message when using file_get_contents on hosts with HTTPS #8493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
batata004 opened this issue May 4, 2022 · 7 comments
Closed

Warning message when using file_get_contents on hosts with HTTPS #8493

batata004 opened this issue May 4, 2022 · 7 comments

Comments

@batata004
Copy link

Description

This bug started happening in the last 30 days when I installed a fresh CentOS with PHP 8.1 and tried to execute the code below. The bug happens with most hosts that use HTTPS (not just in the particular host I showed below):

file_get_contents("https://www.sitepor500.com.br");

The warning I get is this:

Warning</b>: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:0A000126:SSL routines::unexpected eof while reading in <b>/ebs1/apache/www/html

I use PHP for at least 10 years and this is the first time I encounter this error message. I googled it and found some people that managed to find workaround on Ubuntu (not on Centos which I am using) but I think a workaround is not a good solution and so I decided to report this bug here.

A final note: despite file_get_contents showing the warning, it fetchs the content of the URL perfectly, no problem there.

PHP Version

8.1.any

Operating System

Centos 8 Stream

@kocoten1992
Copy link

look very much like #8369

@iluuu1994
Copy link
Member

This is indeed a duplicate of #8369

@batata004
Copy link
Author

I read the #8369 but I cant find the current situation. Is it solved? I read the links inside that thread but the only thing I know is that the bug still remains... right?

@iluuu1994
Copy link
Member

iluuu1994 commented May 5, 2022

@batata004 The other thread is still open so the issue is not solved yet. According to a comment on the bugs.php.net issue there's a workaround. https://gist.github.com/rdh27785/97210d439a280063bd768006450c435d But I haven't tested it.

@batata004
Copy link
Author

@iluuu1994 thank you! I tried the workaround on my server and didnt work. I even rebooted the server in order to make sure openssl was restarted, but the problem remained. I am running Centos 9 Stream.

Anyway, I hope someone fixes this, cause this is causing several problens on many servers I manage (I use buffer manipulation on the output with PHP and warning error messages get in my away). I know I can disable warning messages, but the company that certifies us (provides compliance) does not allow disabling warnings.

@kocoten1992
Copy link

kocoten1992 commented May 6, 2022

would this work for you, guzzle/psr7#504 (comment), this approach does not silence warning.

P/s: it still silence warning, but at least it throw Exception when thing go wrong.

@batata004
Copy link
Author

@kocoten1992 thank you so much! I will take a look at your suggestion and I think it will be of great help!! Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants