gpt4 book ai didi

php - 如何在 PHP 中定义 X509 证书的特定用途

转载 作者:可可西里 更新时间:2023-11-01 13:47:58 24 4
gpt4 key购买 nike

如何将 X.509 证书的用途设置为 X509_PURPOSE_ANY在 PHP 5.x 中?

以下代码输出此警告:

Warning: openssl_csr_new() [function.openssl-csr-new.php]: dn: X509_PURPOSE is not a recognized name in /home/www/index.php on line 45

PHP 脚本:

$Configs = array(       
'config' => 'test.cnf',
'digest_alg' => 'sha1',
'x509_extensions' => 'v3_ca',
'req_extensions' => 'v3_req',
'private_key_bits' => 2048,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
'encrypt_key' => true,
'encrypt_key_cipher' => OPENSSL_CIPHER_3DES);

$ExtraAttribs = array('X509_PURPOSE' => 'X509_PURPOSE_ANY');

//create cert
$dn = array('commonName' => 'Chief');
$privkey = openssl_pkey_new($Configs);
$csr = openssl_csr_new($dn, $privkey, $Configs, $ExtraAttribs);

最后一行是第 45 行。

最佳答案

我找不到任何迹象表明 X509 证书具有“目的”。我只能找到“Basic Constraints”、“Key Usage”和“Enhanced Key Usage”。

我能找到的最接近的是 http://www.openssl.org/docs/apps/verify.html这说

For compatibility with previous versions of SSLeay and OpenSSL a certificate with no trust settings is considered to be valid for all purposes.

关于php - 如何在 PHP 中定义 X509 证书的特定用途,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9594376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com