【问题标题】:Extract serial number from .pfx file using PHP使用 PHP 从 .pfx 文件中提取序列号
【发布时间】:2020-11-26 09:50:35
【问题描述】:

有没有简单的方法使用OpenSSL使用PHP提取证书的序列号?

我尝试使用 openssl 命令将 .pfx 文件转换为 .pem 文件,但我想知道这是否可能纯粹在 PHP 内部实现。

我目前能够从 .pem/.crt 文件中读取序列号,但不能从 .pfx 文件中读取。

感谢您提供的任何帮助

【问题讨论】:

    标签: php openssl


    【解决方案1】:

    您可以使用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";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-08
      • 1970-01-01
      • 1970-01-01
      • 2013-04-30
      • 2016-07-08
      • 2014-10-05
      • 1970-01-01
      相关资源
      最近更新 更多