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
Any help would be appriciated.
Server: Nginx (nginx/1.18.0)
OS: Ubuntu 22.04 LTS
PHP: 7.4.29
Openssl: 1.1.1d
4
Answers
I just had the same issue, it looks like its an issue with OpenSSL on Ubuntu 22.04.
I just updated all my packages on the server and now functionality is working as expected.
Upgrade your nginx 1.18.0 to the mainline version and the problem will be fixed.
To do so:
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor >/usr/share/keyrings/nginx-signing.gpg
.sudo apt update
sudo apt install nginx
Then restart the nginx server.
Try to upgrade your Nginx to 1.22 may help.
On Cent OS 9 Stream, you can install it with the following commmands
This error manifests not only with PHP but in a broad variety of contexts, so I write a generic answer here. The other answers address the issue by upgrading software that have implemented the solution already upstream. The reasons and background is explained here. Most software linking OpenSSL have tickets where they introduce support for the new
openssl
behaviour, e.g. 1, 2, 3. Currently, in Ubuntu 22.04 LTScurl
is version 7.81.0, and fails in case of unexpected EOF with OpenSSL 3.0.x. The latestcurl
is 7.88.1, and apparently resolved the issue, though I could not find the exact commit or ticket. The solution in Ubuntu 22.04 and any system with old curl is to manually compile and install the latest one, as shown for example here.Importantly, the issue can be addressed on client side, you don’t have to do anything with the server (especially that, in most cases, it’s a third party server and works correctly).
TLDR: