Skip to content

8.5 | Regression in openssl_sign() - support for alias algorithms appears to be broken #19369

Closed

Description

@jrfnl

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

Activity

  1. added a commit that references this issue on Aug 9, 2025
  2. added a commit that references this issue on Aug 9, 2025
    c8d7318
  3. added 2 commits that reference this issue on Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions