array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.openssl-spki-export-challenge.php', 1 => 'openssl_spki_export_challenge', ), 'up' => array ( 0 => 'ref.openssl.php', 1 => 'OpenSSL 函数', ), 'prev' => array ( 0 => 'function.openssl-sign.php', 1 => 'openssl_sign', ), 'next' => array ( 0 => 'function.openssl-spki-export.php', 1 => 'openssl_spki_export', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/openssl/functions/openssl-spki-export-challenge.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.6.0, PHP 7, PHP 8)
openssl_spki_export_challenge — 导出与签名公钥和 challenge 相关的 challenge
spki
需要有效的签名公钥和 challenge
返回相关 challenge 字符串,失败返回 false
。
如果 spki
参数传递的是不可用的参数,则抛出 E_WARNING
级别的错误。
示例 #1 openssl_spki_export_challenge() 示例
成功,提取相关联的 challenge 字符串,失败则返回 NULL。
<?php
$pkey = openssl_pkey_new('secret password');
$spkac = openssl_spki_new($pkey, 'challenge string');
$challenge = openssl_spki_export_challenge(preg_replace('/SPKAC=/', '', $spkac));
?>
示例 #2 openssl_spki_export_challenge() 来自 <keygen> 的示例
从 <keygen> 元素中解压相关联的 challenge 字符串。
<?php
$challenge = openssl_spki_export_challenge(preg_replace('/SPKAC=/', '', $_POST['spkac']));
?>
<keygen name="spkac" challenge="challenge string" keytype="RSA">