Skip to content

[Issue] fix: remove dead openssl_free_key() code path in JwkFactory #40761

@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #40688: fix: remove dead openssl_free_key() code path in JwkFactory


Description

Remove the dead openssl_free_key() code path from JwkFactory::freeResource().

Problem

The freeResource() method contains a version check that is always false:

if (\is_resource($resource) && (version_compare(PHP_VERSION, '8.0') < 0)) {
    openssl_free_key($resource);
}

Since Magento requires PHP 8.3+, this condition can never be true. In PHP 8.0+, OpenSSL key resources were replaced with OpenSSLAsymmetricKey objects that are automatically freed by garbage collection, and openssl_free_key() was deprecated (removed in 8.5).

Solution

Remove the dead code path from the method body. The method signature is preserved since it is called from within the class.

Files Changed

  • lib/internal/Magento/Framework/Jwt/JwkFactory.php

⭐ Support my work

Do you like the fix? Remember to react with "👍🏻" to get it merged faster,
Then Sponsor me on Github so I can spend more time on fixing issues like this one.

Learn more at https://github.com/sponsors/lbajsarowicz

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: ready for confirmationReported on 2.4.xIndicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Confirmation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions