openssl_csr_sign
Sign a CSR with another certificate (or itself) and generate a certificate.
openssl_csr_sign Function synopsis
openssl_csr_sign(
OpenSSLCertificateSigningRequest|string $csr,
OpenSSLCertificate|string|null $ca_certificate,
$private_key,
int $days,
?array $options = null,
int $serial = 0,
?string $serial_hex = null
): OpenSSLCertificate|false
Parameters
$csr
TypeOpenSSLCertificateSigningRequest|string
A CSR previously generated by openssl_csr_new.
It can also be the path to a PEM encoded CSR when specified as
file://path/to/csr or an exported string generated
by openssl_csr_export.
$ca_certificate
TypeOpenSSLCertificate|string|null
The generated certificate will be signed by $ca_certificate.
If $ca_certificate is null, the generated certificate
will be a self-signed certificate.
$private_key
$private_key is the private key that corresponds to
$ca_certificate.
$days
Typeint
$days specifies the length of time for which the
generated certificate will be valid, in days.
$options
OptionalType?arrayDefault valuenull
You can finetune the CSR signing by $options.
See openssl_csr_new for more information about
$options.
$serial
OptionalTypeintDefault value0
An optional the serial number of issued certificate. If not specified it will default to 0.
$serial_hex
OptionalType?stringDefault valuenull
An optional hexadecimal string representing the serial number of the
issued certificate. If set, it takes precedence over the
$serial parameter value. If not specified or set
to null, the $serial parameter value is used
instead.
Return value
TypeOpenSSLCertificate|false
Returns an OpenSSLCertificate on success, false on failure.
Changes to the openssl_csr_sign Function
PHP 8.4
- Optional parameter added - #7:
?string $serial_hex = null
openssl_csr_sign(
OpenSSLCertificateSigningRequest|string $csr,
OpenSSLCertificate|string|null $ca_certificate,
$private_key,
int $days,
?array $options = null,
- int $serial = 0
+ int $serial = 0,
+ ?string $serial_hex = null
): OpenSSLCertificate|false PHP 8.2
- Attribute added for parameter
$private_key:#[SensitiveParameter]
PHP 8.0
- Return type added:
OpenSSLCertificate|false - Parameter type added for parameter #1 (
$csr):OpenSSLCertificateSigningRequest|string - Parameter name of parameter #2 changed:
$x509to$ca_certificate - Parameter type added for parameter #2 (
$ca_certificate):OpenSSLCertificate|string|null - Parameter name of parameter #3 changed:
$priv_keyto$private_key - Parameter type added for parameter #4 (
$days):int - Parameter name of parameter #5 changed:
$config_argsto$options - Parameter type added for parameter #5 (
$options):?array - Parameter default value added for position #5 (
$options):null - Parameter type added for parameter #6 (
$serial):int - Parameter default value added for position #6 (
$serial):0
openssl_csr_sign(
- $csr,
+ OpenSSLCertificateSigningRequest|string $csr,
- $x509,
+ OpenSSLCertificate|string|null $ca_certificate,
- $priv_key,
+ $private_key,
- $days,
+ int $days,
- $config_args,
+ ?array $options = null,
- $serial
+ int $serial = 0
- )
+ ): OpenSSLCertificate|false openssl_csr_sign Function Availability
openssl_csr_sign Function Availability| PHP Version | Availability |
|---|---|
| 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 |