Skip to content

openssl_pkey_new() fails on OpenSSL 3.6 - missing private_key_bits parameter #445

@ben182

Description

@ben182

Description

On systems with OpenSSL 3.6.0, the Encryption::createLocalKeyObject() method fails with:

openssl_pkey_new(): Private key length must be at least 384 bits, configured to 0

Environment

  • PHP: 8.4 / 8.5
  • OpenSSL: 3.6.0 (released October 2025)
  • web-push: 10.0.1

Cause

OpenSSL 3.6 now requires an explicit private_key_bits parameter for EC key generation. The current code in
src/Encryption.php:254 does not provide this:

$keyResource = openssl_pkey_new([                                                                                        
    'curve_name'       => 'prime256v1',                                                                                  
    'private_key_type' => OPENSSL_KEYTYPE_EC,                                                                            
]);                                                                                                                      
                                                                                                                         
Fix                                                                                                                      
                                                                                                                         
Add private_key_bits to the options array:                                                                               
                                                                                                                         
$keyResource = openssl_pkey_new([                                                                                        
    'curve_name'       => 'prime256v1',                                                                                  
    'private_key_type' => OPENSSL_KEYTYPE_EC,                                                                            
    'private_key_bits' => 384,                                                                                           
]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions