I have a website running on an Nginx web server. I implemented the Google reCaptcha tool to stop spam.
The server is Nginx 1.18.0 with php7.4-fpm supported. Everything is OK with this configuration.
Recently, I am working on the development of a new version of this site. I want newer Nginx and php-fpm versions.
So I test the same code on Nginx 1.21.6 and php8.0-fpm. The error comes out every time I call the reCaptcha php lib.
To make it clear, I use the reCaptcha php lib demo to repeat the error or warning.
The code is fetched from the Github Google / recaptcha repos
There are five demo pages. On php8.0-fpm, I tested every page. They are showing the same error or can not show the response.
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:0A000126:SSL routines::unexpected eof while reading in /home/davidyin/example.com/test/recaptcha/vendor/ReCaptcha/RequestMethod/Post.php on line 80
Here is a sample of the errors:
I did some search and find most results are not helpful for the error: 0A000126
Some posts mentioned that it is the PHP language problem, some said it is because of OpenSSL 3.0.
In one post, I saw it pointed out that php8.1 has fixed the problem of it.
So, I tried to run the demo pages on php8.1-fpm. Actually PHP 8.1.6. The error is gone and the correct response is displayed.
Conclusion
When upgrading the PHP language program or website from 7.4 to 8.0 with reCaptcha lib, try directly upgrading to php8.1.
php8.0 and openSSL 3.0 are not perfect match.