【发布时间】:2020-11-26 09:50:35
【问题描述】:
有没有简单的方法使用OpenSSL使用PHP提取证书的序列号?
我尝试使用 openssl 命令将 .pfx 文件转换为 .pem 文件,但我想知道这是否可能纯粹在 PHP 内部实现。
我目前能够从 .pem/.crt 文件中读取序列号,但不能从 .pfx 文件中读取。
感谢您提供的任何帮助
【问题讨论】:
有没有简单的方法使用OpenSSL使用PHP提取证书的序列号?
我尝试使用 openssl 命令将 .pfx 文件转换为 .pem 文件,但我想知道这是否可能纯粹在 PHP 内部实现。
我目前能够从 .pem/.crt 文件中读取序列号,但不能从 .pfx 文件中读取。
感谢您提供的任何帮助
【问题讨论】:
您可以使用chilkat php extension 并使用以下代码:
include("chilkat_9_5_0.php");
$cert = new CkCert();
$pfxFilename = '/your/path/to.pfx';
$pfxPassword = 'test';
$success = $cert->LoadPfxFile($pfxFilename,$pfxPassword);
if ($success != true) {
print $cert->lastErrorText() . "\n";
exit;
}
print 'Serial Number:' . $cert->serialNumber() . "\n";
【讨论】: