(Perl) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.
Note: This example requires Chilkat v10.0.0 or greater.
use chilkat();
$certStore = chilkat::CkCertStore->new();
# On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
# The argument passed to OpenCurrentUserStore is ignored.
$success = $certStore->OpenCurrentUserStore(0);
if ($success == 0) {
print $certStore->lastErrorText() . "\r\n";
exit;
}
$numCerts = $certStore->get_NumCertificates();
print "numCerts = " . $numCerts . "\r\n";
$i = 0;
while ($i < $numCerts) {
# cert is a Cert
$cert = $certStore->GetCertificate($i);
print $cert->subjectDN() . "\r\n";
print $cert->subjectCN() . "\r\n";
print $cert->serialNumber() . "\r\n";
print "----" . "\r\n";
$i = $i + 1;
}
$certStore->CloseCertStore();
|