我想对CSR进行解码,并想要它的详细信息和ASN.1信息。
我正在使用以下功能
$cert_data = openssl_csr_get_public_key($csr);
$cert_details = openssl_pkey_get_details($cert_data);
$cert_key = $cert_details['key'];
$cert_subject = openssl_csr_get_subject($csr);
但只能获取以下信息:
Array
(
[subject] => Array
(
[C] => GB
[ST] => Staffordshire
[L] => Stoke on Trent
[O] => Red Kestrel Consulting Ltd
[CN] => testcert.redkestrel.co.uk
)
[key] => -----BEGIN PUBLIC KEY-----
-----END PUBLIC KEY-----
[details] => Array
(
[bits] => 2048
[key] => -----BEGIN PUBLIC KEY-----
-----END PUBLIC KEY-----
[rsa] => Array
()
[type] => 0
)
先谢谢了。 :)
答案 0 :(得分:0)
您可以使用PHP库'phpseclib'并执行类似的操作。
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$csrInPEM = file_get_contents(__DIR__ . '/server.csr');
$x509 = new \phpseclib\File\X509();
$spkac = $x509->loadCSR($csrInPEM);
var_dump($spkac);