(PHP 5 >= 5.6.0, PHP 7, PHP 8)
openssl_spki_verify — 验证签名公钥和 challenge
spki
期望有效的签名公钥和 challenge。
如果传递给 digest_algo
的参数不是可用的参数,将会抛出 E_WARNING
级别的错误。
示例 #1 openssl_spki_verify() 示例
验证现有签名公钥和 challenge
<?php
$pkey = openssl_pkey_new('secret password');
$spkac = openssl_spki_new($pkey, 'challenge string');
if (openssl_spki_verify(preg_replace('/SPKAC=/', '', $spkac))) {
echo $spkac;
} else {
echo "SPKAC validation failed";
}
?>
示例 #2 openssl_spki_verify() 来自 <keygen> 的示例
通过 <keygen> 元素验证现有签名公钥和 challenge
<?php
if (openssl_spki_verify(preg_replace('/SPKAC=/', '', $_POST['spkac']))) {
echo $spkac;
} else {
echo "SPKAC validation failed";
}
?>
<keygen name="spkac" challenge="challenge string" keytype="RSA">