openssl_x509_checkpurpose

FunctionParams and return types changed in PHP 8.0

Verifies if a certificate can be used for a particular purpose.

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

openssl_x509_checkpurpose Function synopsis

openssl_x509_checkpurpose(
    OpenSSLCertificate|string $certificate,
    int $purpose,
    array $ca_info = [],
    ?string $untrusted_certificates_file = null
  ): int|bool

Parameters

$certificate

TypeOpenSSLCertificate|string

The examined certificate.

$purpose

Typeint

These options are not bitfields - you may specify one only!

$ca_info

OptionalTypearrayDefault value[]

$ca_info should be an array of trusted CA files/dirs as described in Certificate Verification.

$untrusted_certificates_file

OptionalType?stringDefault valuenull

If specified, this should be the name of a PEM encoded file holding certificates that can be used to help verify the certificate, although no trust is placed in the certificates that come from that file.

Return value

Typeint|bool

Returns true if the certificate can be used for the intended purpose, false if it cannot, or -1 on error.

Changes to the openssl_x509_checkpurpose Function

PHP 8.0

  • Return type added: int|bool
  • Parameter name of parameter #1 changed: $x509cert to $certificate
  • Parameter type added for parameter #1 ($certificate): OpenSSLCertificate|string
  • Parameter type added for parameter #2 ($purpose): int
  • Parameter name of parameter #3 changed: $cainfo to $ca_info
  • Parameter type added for parameter #3 ($ca_info): array
  • Parameter default value added for position #3 ($ca_info): []
  • Parameter name of parameter #4 changed: $untrustedfile to $untrusted_certificates_file
  • Parameter type added for parameter #4 ($untrusted_certificates_file): ?string
  • Parameter default value added for position #4 ($untrusted_certificates_file): null
  openssl_x509_checkpurpose(
-     $x509cert,
+     OpenSSLCertificate|string $certificate,
-     $purpose,
+     int $purpose,
-     $cainfo,
+     array $ca_info = [],
-     $untrustedfile
+     ?string $untrusted_certificates_file = null
-   )
+   ): int|bool

openssl_x509_checkpurpose Function Availability

PHP VersionAvailability
PHP 8.5Future Release Yes
PHP 8.4Upcoming Release Yes
PHP 8.3Supported (Latest) Yes
PHP 8.2Supported Yes
PHP 8.1Security-Fixes Only 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