openssl_pkcs7_verify
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
openssl_pkcs7_verify — 校验一个已签名的 S/MIME 消息的签名
说明
   openssl_pkcs7_verify(
string
int
?string
array
?string
?string
?string
): bool|int
  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): bool|int
openssl_pkcs7_verify() 读取给定文件中的 S/MIME 消息并且检查数字签名。
参数
- input_filename
- 
      消息的路径。 
- flags
- 
      flags可以用来影响如何校验签名 - 参见 PKCS7 常量 获取更多信息。
- signers_certificates_filename
- 
      如果已指定 signers_certificates_filename输出文件,它应该是一个用以保存文件的字符串名称,签名消息的个人证书将以 PEM 的格式保存起来。
- ca_info
- 
      如果 ca_info被指定了,它应该保存关于受信任的CA证书的信息供在验证过程中使用 - 参见 证书校验 获取关于该参数的更多信息。
- untrusted_certificates_filename
- 
      如果 untrusted_certificates_filename被指定了,该文件包含了一堆会被作为不受信任的ca使用的证书。
- content
- 
      你可以使用 content来指定带有已被验证数据的文件名,该文件内容已去掉了签名信息。
- output_filename
- 
      
更新日志
| 版本 | 说明 | 
|---|---|
| 8.0.0 | signers_certificates_filename、untrusted_certificates_filename、content和output_filename现在可为 null。 | 
| 7.2.0 | 新增 output_filename参数。 | 
注释
注意: 正如 RFC 2045 中指定的,
input_filename参数最多不可超过 76 个字符串。
  +添加备注
  
用户贡献的备注 1 note
  
  
  reg1barclay at REMOVETHIS dot live dot it ¶
  
 
6 years ago
  To verify a .p7m file with openssl_pkcs7_verify() you must convert it to S/MIME format. For example...
<?php
function der2smime($file)
{
$to=<<<TXT
MIME-Version: 1.0
Content-Disposition: attachment; filename="smime.p7m"
Content-Type: application/x-pkcs7-mime; smime-type=signed-data; name="smime.p7m"
Content-Transfer-Encoding: base64
\n
TXT;
$from=file_get_contents($file);
$to.=chunk_split(base64_encode($from));
    return file_put_contents($file,$to);
}
?>备份地址:http://www.lvesu.com/blog/php/function.openssl-pkcs7-verify.php