php-src icon indicating copy to clipboard operation
php-src copied to clipboard

openssl_error_string() returns errors left by a previous request

Open ArtUkrainskiy opened this issue 2 weeks ago • 0 comments

Description

OpenSSL errors from one request show up in the next request of the same worker. PHP keeps them in OPENSSL_G(errors), which is only freed in GSHUTDOWN.

php-fpm with pm = static and pm.max_children = 1, so both requests hit one worker:

<?php
if ($_SERVER['QUERY_STRING'] === 'fail') {
    @openssl_x509_read('not a certificate');
} else {
    var_dump(openssl_error_string());
}

Request ?fail, then ?check.

Resulted in this output:

string(42) "error:0480006C:PEM routines::no start line"

But I expected this output instead:

bool(false)

I think the queue should be cleared in RSHUTDOWN. I can send a PR.

PHP Version

PHP 8.7.0-dev (master). The same code is in 8.3, 8.4 and 8.5.

Operating System

Ubuntu 26.04, OpenSSL 3.5.5

ArtUkrainskiy avatar Nov 17 '26 15:11 ArtUkrainskiy