[php-src] Issue #19369: 8.5 | Regression in openssl_sign() - support for alias algorithms appears to be broken
| From: | jrfnl | Date: | Mon, 04 Aug 2025 18:18:49 +0000 |
| Subject: | [php-src] Issue #19369: 8.5 | Regression in openssl_sign() - support for alias algorithms appears to be broken | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250559@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19369
Author: jrfnl
### Description
The following code:
```php
<?php
var_dump(openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption'));
```
Resulted in this output:
```
openssl_sign(): Unknown digest algorithm
```
But I expected this output instead:
```
true
```
### Analysis
PR #18516 has been identified as the cause of this regression. @nielsdos has already run a bisect
(thanks!) and confirmed that commit https://github.com/php/php-src/commit/2f5ef4d2b729227f5847dd36faba94ee430cd096
is the culprit. /cc @bukka
### Test
The following test should be able to safeguard against this regression:
```phpt
--TEST--
openssl_sign: alias algorithm
--EXTENSIONS--
openssl
--FILE--
<?php
$digests = openssl_get_md_methods();
$digests_and_aliases = openssl_get_md_methods(true);
$digest_aliases = array_diff($digests_and_aliases, $digests);
$data = "Testing openssl_sign() with alias algorithm";
$privkey = "file://" . __DIR__ . "/private_rsa_1024.key";
// If things work correctly, there should be no output.
foreach ($digest_aliases as $alias) {
if (openssl_sign($data, $sign, $privkey, $alias) === false) {
echo 'openssl_sign() failing with alias ', $alias, PHP_EOL;
}
}
?>
--EXPECT--
```
If it helps, the test can be found in this commit: https://github.com/jrfnl/php-src/commit/fb624b6d41faa9f09f897fcf1979bdbed07d0791
Found via: https://github.com/PHPMailer/PHPMailer/actions/runs/16728360948/job/47350003979#step:9:33
### PHP Version
```plain
master branch
```
### Operating System
not relevant