简体   繁体   中英

Extract serial number from .pfx file using PHP

Is there a simple way using OpenSSL to extract the serial number of a certificate using PHP?

I've tried converting the.pfx file to a.pem file using an openssl command, but I'm wondering if it's possible purely inside PHP.

I'm currently able to read the serial number from a.pem/.crt file, but not from a.pfx file.

Thank you for any help given

You may use chilkat php extension and use following code:

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";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM