The manual is not constistent at this point. On one hand, it describes the return as digest/fingerprint of a cert, on the other hand it says:
bool openssl_x509_fingerprint( … )
On PHP 5.6.5, I only get the bool return (1 or 0).
PHP - Manual: openssl_x509_fingerprint
2024-12-21
(PHP 5 >= 5.6.0, PHP 7, PHP 8)
openssl_x509_fingerprint — 计算一个给定的x.509证书的指纹或摘要
$x509
, string $hash_algorithm
= "sha1", bool $raw_output
= false
): string
openssl_x509_fingerprint() 返回x509
的字符串类型的摘要。
x509
参见密钥/证书参数以获取有效值列表。
hash_algorithm
使用的摘要方法或散列算法,比如, "sha256", openssl_get_md_methods()摘要算法之一。
raw_output
设置为 true
时,输出原始二进制数据。设置为 false
时,输出小写的16进制字符串。
将包含计算的证书指纹的字符串返回为小写16进制格式,除非将raw_output
设置为TRUE,在这种情况下会返回消息摘要的原始二进制表示形式。
失败则返回 false
.
The manual is not constistent at this point. On one hand, it describes the return as digest/fingerprint of a cert, on the other hand it says:
bool openssl_x509_fingerprint( … )
On PHP 5.6.5, I only get the bool return (1 or 0).
官方地址:https://www.php.net/manual/en/function.openssl-x509-fingerprint.php