Perl Requires Chilkat v10.1.2+
Chilkat2 Perl
Apple Keychain - List Certificates
See more Apple Keychain Examples
Iterates over the certificates in the Apple Keychain.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $certStore = Chilkat2::CertStore->new;
# On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
# The argument passed to OpenCurrentUserStore is ignored.
my $success = $certStore->OpenCurrentUserStore(0);
if (!$success) {
print $certStore->LastErrorText, "\n";
exit;
}
my $numCerts = $certStore->NumCertificates;
print 'numCerts = ', $numCerts, "\n";
my $cert = Chilkat2::Cert->new;
my $i = 0;
while ($i < $numCerts) {
$certStore->GetCert($i, $cert);
print $cert->SubjectDN, "\n";
print $cert->SubjectCN, "\n";
print $cert->SerialNumber, "\n";
print "----\n";
$i = $i + 1;
}
$certStore->CloseCertStore();