You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary
When using PHP with OpenSSL 3.x in FIPS mode (as enabled by default in certain environments such as Amazon Linux 2023), the openssl_pkey_export() function fails when a passphrase is provided.
This is due to the use of legacy OpenSSL APIs (PEM_write_bio_PrivateKey() → PEM_write_bio_PrivateKey_traditional() → EVP_CipherInit_ex()), which are not FIPS-compliant in OpenSSL 3.x.
Affected:
PHP 8.1 – 8.4
OpenSSL 3.x in FIPS mode
PHP’s built-in openssl extension
openssl_pkey_export($key, $out, $passphrase) when $passphrase is provided
In OpenSSL 3 FIPS mode, manual cipher encryption is disallowed.
Only provider-based encryption (via OSSL_ENCODER, etc.) is allowed.
This behavior is documented in the OpenSSL 3.x migration guide and FIPS module guide:
Applications should no longer rely on implicit fetches of algorithms
or manually configure cipher contexts outside the provider framework.
Expected Behavior
If the system is in FIPS mode and the passphrase is provided,
openssl_pkey_export() should either:
Properly export the key using a FIPS-compliant provider mechanism (e.g., via OSSL_ENCODER)
Or fail with a clear message that encrypted exports are not supported under current conditions
As a note, my openssl is configured properly and I can generate a private key with a passphrase via the command line. Also, if you leave the passphrase out of the call openssl_pkey_export() it does work without encryption.
PHP Version
PHP 8.1.32 (cli) (built: Mar 11 2025 22:09:20) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.32, Copyright (c) Zend Technologies
with Zend OPcache v8.1.32, Copyright (c), by Zend Technologies
Operating System
No response
The text was updated successfully, but these errors were encountered:
Description
Summary
When using PHP with OpenSSL 3.x in FIPS mode (as enabled by default in certain environments such as Amazon Linux 2023), the openssl_pkey_export() function fails when a passphrase is provided.
This is due to the use of legacy OpenSSL APIs (PEM_write_bio_PrivateKey() → PEM_write_bio_PrivateKey_traditional() → EVP_CipherInit_ex()), which are not FIPS-compliant in OpenSSL 3.x.
Affected:
PHP 8.1 – 8.4
OpenSSL 3.x in FIPS mode
PHP’s built-in openssl extension
openssl_pkey_export($key, $out, $passphrase) when $passphrase is provided
Reproduction
When run under OpenSSL 3.x with FIPS enabled, the call fails with:
error:0308010C:digital envelope routines::unsupported
Root Cause (maybe?)
Internally, PHP uses:
In OpenSSL 3 FIPS mode, manual cipher encryption is disallowed.
Only provider-based encryption (via OSSL_ENCODER, etc.) is allowed.
This behavior is documented in the OpenSSL 3.x migration guide and FIPS module guide:
Applications should no longer rely on implicit fetches of algorithms
or manually configure cipher contexts outside the provider framework.
Expected Behavior
If the system is in FIPS mode and the passphrase is provided,
openssl_pkey_export() should either:
Properly export the key using a FIPS-compliant provider mechanism (e.g., via OSSL_ENCODER)
Or fail with a clear message that encrypted exports are not supported under current conditions
As a note, my openssl is configured properly and I can generate a private key with a passphrase via the command line. Also, if you leave the passphrase out of the call openssl_pkey_export() it does work without encryption.
PHP Version
PHP 8.1.32 (cli) (built: Mar 11 2025 22:09:20) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.32, Copyright (c) Zend Technologies
with Zend OPcache v8.1.32, Copyright (c), by Zend Technologies
Operating System
No response
The text was updated successfully, but these errors were encountered: