openssl_pkey_new

FunctionParams and return types changed in PHP 8.0

Generates a new private key.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

openssl_pkey_new Function synopsis

openssl_pkey_new(?array $options = null): OpenSSLAsymmetricKey|false

Parameters

$options

OptionalType?arrayDefault valuenull

It is possible to fine-tune the key generation (e.g. specifying the number of bits or parameters) using the $options parameter. These options can either be algorithm-specific parameters used for key generation, or generic options used also in _CSR_generation if not specified. See openssl_csr_new for more information about how to use $options for a CSR. Among those options only private_key_bits, private_key_type, curve_name, and config are used for key generation. Algorithm-specific options are used if the associative array includes one of the specific keys.

Return value

TypeOpenSSLAsymmetricKey|false

Returns an OpenSSLAsymmetricKey instance for the pkey on success, or false on error.

Changes to the openssl_pkey_new Function

PHP 8.0

  • Return type added: OpenSSLAsymmetricKey|false
  • Parameter name of parameter #1 changed: $configargs to $options
  • Parameter type added for parameter #1 ($options): ?array
  • Parameter default value added for position #1 ($options): null
- openssl_pkey_new($configargs)
+ openssl_pkey_new(?array $options = null): OpenSSLAsymmetricKey|false

openssl_pkey_new Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes