openssl_pkcs7_verify

FunctionParams and return types changed in PHP 8.0

Verifies the signature of an S/MIME signed message.

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_pkcs7_verify Function synopsis

openssl_pkcs7_verify(
    string $input_filename,
    int $flags,
    ?string $signers_certificates_filename = null,
    array $ca_info = [],
    ?string $untrusted_certificates_filename = null,
    ?string $content = null,
    ?string $output_filename = null
  ): int|bool

Parameters

$input_filename

Typestring

Path to the message.

$flags

Typeint

$flags can be used to affect how the signature is verified - see PKCS7 constants for more information.

$flags accepts one or a bitmask of the following constant values:

$signers_certificates_filename

OptionalType?stringDefault valuenull

If the $signers_certificates_filename is specified, it should be a string holding the name of a file into which the certificates of the persons that signed the messages will be stored in PEM format.

$ca_info

OptionalTypearrayDefault value[]

If the $ca_info is specified, it should hold information about the trusted CA certificates to use in the verification process - see certificate verification for more information about this parameter.

$untrusted_certificates_filename

OptionalType?stringDefault valuenull

If the $untrusted_certificates_filename is specified, it is the filename of a file containing a bunch of certificates to use as untrusted CAs.

$content

OptionalType?stringDefault valuenull

You can specify a filename with $content that will be filled with the verified data, but with the signature information stripped.

$output_filename

OptionalType?stringDefault valuenull

Return value

Typeint|bool

Returns true if the signature is verified, false if it is not correct (the message has been tampered with, or the signing certificate is invalid), or -1 on error.

Changes to the openssl_pkcs7_verify Function

PHP 8.0

  • Return type added: int|bool
  • Parameter name of parameter #1 changed: $filename to $input_filename
  • Parameter type added for parameter #1 ($input_filename): string
  • Parameter type added for parameter #2 ($flags): int
  • Parameter name of parameter #3 changed: $signerscerts to $signers_certificates_filename
  • Parameter type added for parameter #3 ($signers_certificates_filename): ?string
  • Parameter default value added for position #3 ($signers_certificates_filename): null
  • Parameter name of parameter #4 changed: $cainfo to $ca_info
  • Parameter type added for parameter #4 ($ca_info): array
  • Parameter default value added for position #4 ($ca_info): []
  • Parameter name of parameter #5 changed: $extracerts to $untrusted_certificates_filename
  • Parameter type added for parameter #5 ($untrusted_certificates_filename): ?string
  • Parameter default value added for position #5 ($untrusted_certificates_filename): null
  • Parameter type added for parameter #6 ($content): ?string
  • Parameter default value added for position #6 ($content): null
  • Parameter name of parameter #7 changed: $pk7 to $output_filename
  • Parameter type added for parameter #7 ($output_filename): ?string
  • Parameter default value added for position #7 ($output_filename): null
  openssl_pkcs7_verify(
-     $filename,
+     string $input_filename,
-     $flags,
+     int $flags,
-     $signerscerts,
+     ?string $signers_certificates_filename = null,
-     $cainfo,
+     array $ca_info = [],
-     $extracerts,
+     ?string $untrusted_certificates_filename = null,
-     $content,
+     ?string $content = null,
-     $pk7
+     ?string $output_filename = null
-   )
+   ): int|bool

PHP 7.2

  • Optional parameter added - #7: $pk7
 openssl_pkcs7_verify(
     $filename,
     $flags,
     $signerscerts,
     $cainfo,
     $extracerts,
-    $content
+    $content,
+    $pk7
   )

openssl_pkcs7_verify 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