openssl_x509_verify

PHP 7 >= 7.4.0, PHP 8
openssl_x509_verify - Verifies digital signature of x509 certificate against a public key
Manual
Code Examples

openssl_x509_verify(
     OpenSSLCertificate|string$certificate,
     OpenSSLAsymmetricKey|OpenSSLCertificate|array|string$public_key
): int

openssl_x509_verify verifies that the certificate certificate was signed by the private key corresponding to public key public_key.

Parameters

x509

See Key/Certificate parameters for a list of valid values.

public_key

OpenSSLAsymmetricKey - a key, returned by openssl_get_publickey

string - a PEM formatted key, example, "-----BEGIN PUBLIC KEY----- MIIBCgK..."

Return Values

Returns 1 if the signature is correct, 0 if it is incorrect, and -1 on error.

Changelog

Version Description
8.0.0 certificate accepts an OpenSSLCertificate instance now; previously, a resource of type OpenSSL X.509 was accepted.
8.0.0 public_key accepts an OpenSSLAsymmetricKey or OpenSSLCertificate instance now; previously, a resource of type OpenSSL key or OpenSSL X.509 was accepted.

Related Functions

Example of openssl_x509_verify

Show all examples for openssl_x509_verify

PHP Version:


Function openssl_x509_verify:

OpenSSL Functions

Most used PHP functions