-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Description
Description
The following code:
<?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
Found via: https://github.com/PHPMailer/PHPMailer/actions/runs/16728360948/job/47350003979#step:9:33
Analysis
PR #18516 has been identified as the cause of this regression. @nielsdos has already run a bisect (thanks!) and confirmed that commit 2f5ef4d is the culprit. /cc @bukka
Test
The following test should be able to safeguard against this regression:
--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: jrfnl@fb624b6 - let me know if you want me to open a PR to add the test.
As per the above, the test would currently fail on PHP 8.5.
PHP Version
`master` branch
Operating System
not relevant