PHP8 openssl_x509_check_private_key

2024-03-13 11:24 更新

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

openssl_x509_check_private_key — 检查私钥是否对应于证书

说明

openssl_x509_check_private_key(OpenSSLCertificate|string $certificate, OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key): bool

检查指定的私钥 private_key 是否和证书 certificate 对应。

警告

这个函数不会检查密钥 private_key 是否真的是私钥。 它只是比较了和密钥匹配的公共材料 (比如,RSA 密钥的指数和模量) 和/或密钥参数(比如,EC 密钥的参数)。

这也意味着,比如,提供给 private_key 赋一个公钥值,该函数可能返回 true。

参数 

certificate

证书。

private_key

私钥。

返回值 

如果指定的私钥 private_key 和证书 certificate 对应,返回 true 否则返回 false。

更新日志 

版本说明
8.0.0certificate 现在接受 OpenSSLCertificate 实例;之前接受类型 OpenSSL X.509 的 resource。
8.0.0private_key 现在接受 OpenSSLAsymmetricKey 或 OpenSSLCertificate 实例;之前接受类型 OpenSSL key 或 OpenSSL X.509 的 resource。


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号