Skip to content
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

error:0A000126:SSL routines::unexpected eof while reading in php #18574

Closed
msalik42 opened this issue Jun 15, 2022 · 9 comments
Closed

error:0A000126:SSL routines::unexpected eof while reading in php #18574

msalik42 opened this issue Jun 15, 2022 · 9 comments
Labels
resolved: answered The issue contained a question which has been answered triaged: question The issue contains a question

Comments

@msalik42
Copy link

I have built a website in PHP using the YII2 framework. When I use file_get_contents($requestUrl, false, stream_context_create($arrContextOptions)) then i am getting error saying error:0A000126:SSL routines::unexpected eof while reading I have also tried to enable the legacy provider by editing the openssl.cnf file, but got no success. Reference: https://gist.github.com/rdh27785/97210d439a280063bd768006450c435d

Here is the screenshot

Server: Nginx (nginx/1.18.0)
OS: Ubuntu 22.04 LTS
PHP: 7.4.29
Openssl: 1.1.1d

@msalik42 msalik42 added the issue: question The issue was opened to ask a question label Jun 15, 2022
@beldmit
Copy link
Member

beldmit commented Jun 15, 2022

It has nothing to do with legacy provider. SSL_OP_IGNORE_UNEXPECTED_EOF is the corresponding flag to ignore this error, see https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html for more information

@beldmit beldmit added triaged: question The issue contains a question and removed issue: question The issue was opened to ask a question labels Jun 15, 2022
@t8m t8m added the resolved: answered The issue contained a question which has been answered label Jun 15, 2022
@jessuppi
Copy link

jessuppi commented Jul 12, 2022

This error is popping up all over GitHub and StackOverflow, I don't know why this issue is marked "resolved"... it seems there is a bug in OpenSSL that requires upgrading and/or downgrading packages, and/or rebooting.

Ref: curl/curl#5138
Ref: https://stackoverflow.com/questions/72627218/
Ref: https://stackoverflow.com/questions/60888230/

...among several other threads.

It seems to happen in both 1.1.1d and 1.1.1e, possibly other versions.

Edit: this comment seems relevant:

Yes, it's a probably a bad server that closes a connection abruptly. But these servers are quite common, see also curl/curl#4409. It was fixed with curl/curl#4623 , but openssl changed behavior with 1.1.1e and doesn't return SSL_ERROR_SYSCALL, but SSL_ERROR_SSL now and errors are back in different form.

P.S. Rumors are that 1.1.1f (v3.0.x) fixes this issue but I just came across it on Ubuntu 22.04 and OpenSSL 3.0.2 so I'm not sure if this was ever truly resolved or not.

@t8m
Copy link
Member

t8m commented Jul 12, 2022

Not rumors but facts:

1.1.1f reverted the behavior the error is reported. The error is really an error of the peer.

3.0.x requires the application to set the SSL_OP_IGNORE_UNEXPECTED_EOF to ignore the error.

@t8m t8m closed this as completed Jul 12, 2022
@SalihSyr
Copy link

Can anyone show me how to set the SSL_OP_IGNORE_UNEXPECTED_EOF to the ssl.h ?

@t8m
Copy link
Member

t8m commented Jul 13, 2022

The application has to set it. It has to call SSL_CTX_set_options(ctx, SSL_OP_IGNORE_UNEXPECTED_EOF);

@SalihSyr
Copy link

I added the function but it still doesn't work.
Screenshot 2022-07-13 120136

@t8m
Copy link
Member

t8m commented Jul 13, 2022

You're editing an OpenSSL header file, not modifying the application calling the OpenSSL. Anyway, this should be done by the application developer, not by user.

@SalihSyr
Copy link

Oh I got it. Well when I downgraded it to an older version of openssl it still didn't work.

Do you know a version where it deffinetly won't make problems?

@t8m
Copy link
Member

t8m commented Jul 13, 2022

Use the latest 1.1.1 release (1.1.1q).

markstory added a commit to cakephp/cakephp that referenced this issue Jul 25, 2022
Ubuntu 22.04 comes with OpenSSL 3, and the specific version that PHP is
built against has a bug which has since been fixed but isn't showing up
in the images that GitHub has available.

See openssl/openssl#18574
and php/php-src#8369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved: answered The issue contained a question which has been answered triaged: question The issue contains a question
Projects
None yet
Development

No branches or pull requests

5 participants