(Perl) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.Note: This example requires Chilkat v10.1.2 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";
$cert = chilkat::CkCert->new();
$i = 0;
while ($i < $numCerts) {
$certStore->GetCert($i,$cert);
print $cert->subjectDN() . "\r\n";
print $cert->subjectCN() . "\r\n";
print $cert->serialNumber() . "\r\n";
print "----" . "\r\n";
$i = $i + 1;
}
$certStore->CloseCertStore();
|