Screenshot is here
I have built a trang web 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 lớn enable the legacy provider by editing the openssl.cnf tệp tin, 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
asked Jun 15, 2022 at 7:11
Salik MohammadSalik Mohammad
3111 gold badge3 silver badges6 bronze badges
3
This error manifests not only with PHP but in a broad variety of contexts, ví 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 tư vấn for the new openssl
behaviour, e.g. 1, 2, 3. Currently, in Ubuntu 22.04 LTS curl
is version 7.81.0, and fails in case of unexpected EOF with OpenSSL 3.0.x. The latest curl
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 lớn 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 lớn vì thế anything with the server (especially that, in most cases, it's a third các buổi party server and works correctly).
TLDR:
apt remove curl
apt purge curl
apt-get update
apt-get install -y libssl-dev autoconf libtool make
cd /usr/local/src
wget https://curl.haxx.se/download/curl-7.88.1.zip
unzip curl-7.88.1.zip
cd curl-7.88.1
./buildconf
./configure --with-ssl
make
sudo make install
sudo cp /usr/local/bin/curl /usr/bin/curl
sudo ldconfig
curl -V
answered Mar 28, 2023 at 14:35
deeenesdeeenes
4,5765 gold badges46 silver badges60 bronze badges
9
I just had the same issue, it looks lượt thích 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.
sudo apt update && sudo apt upgrade -y
answered Jun 21, 2022 at 9:17
lkylky
1,1393 gold badges18 silver badges37 bronze badges
4
Upgrade your nginx 1.18.0 to lớn the mainline version and the problem will be fixed. To vì thế so:
- Execute as sudo:
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor >/usr/share/keyrings/nginx-signing.gpg
. - ADD THE LINES in /etc/apt/sources.list:
deb [signed-by=/usr/share/keyrings/nginx-signing.gpg] https://nginx.org/packages/mainline/ubuntu/ jammy nginx
deb-src [signed-by=/usr/share/keyrings/nginx-signing.gpg] https://nginx.org/packages/mainline/ubuntu/ jammy nginx
sudo apt update
sudo apt install nginx
Then restart the nginx server.
answered Aug 15, 2022 at 19:57
Ankit SinghAnkit Singh
1093 silver badges12 bronze badges
2
Another possible reason you may be getting this error is if a firewall is blocking your traffic from the machine to lớn the mạng internet.
In my case, it was an Ubuntu 22.04 LTS machine, behind an Azure Firewall. The firewall was configured to lớn only allow certain categories, and the sites I was trying to lớn talk to lớn were not in the allowed category.
In your case it may be a different kind of rule blocking it however. You may wish to lớn review the logs from your firewall to lớn know if it is blocking it and why.
answered Dec 5, 2023 at 21:59
Try to lớn upgrade your Nginx to lớn 1.22 may help.
On Cent OS 9 Stream, you can install it with the following commmands
dnf module list nginx
dnf module reset nginx
dnf module install nginx:1.22
answered Jan 4, 2023 at 13:11
Haozhe XieHaozhe Xie
3,6467 gold badges31 silver badges56 bronze badges