Perl Requires Chilkat v10.1.2+
Chilkat2 Perl
Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $certStore = Chilkat2::CertStore->new;
# This only loads the contents of the PFX file into the certStore object.
# It is not importing the PFX into the Windows certificate stores.
my $pfxPassword = 'badssl.com';
my $success = $certStore->LoadPfxFile('qa_data/pfx/badssl.com-client.p12', $pfxPassword);
if (!$success) {
print $certStore->LastErrorText, "\n";
exit;
}
# Examine each certificate (loaded from the PFX) in this certStore object
my $cert = Chilkat2::Cert->new;
my $numCerts = $certStore->NumCertificates;
my $i = 0;
while ($i < $numCerts) {
$certStore->GetCert($i, $cert);
print 'hasPrivateKey=', ($cert->HasPrivateKey() ? 1 : 0), ', ', $cert->SubjectCN, "\n";
$i = $i + 1;
}