PHP Extension
PHP Extension
Apple Keychain - List Certs on Smartcards and USB Tokens
See more Apple Keychain Examples
Iterates over the certificatse on connected smartcards and USB tokens via the Apple Keychain.Chilkat PHP Extension Downloads
<?php
include("chilkat.php");
$success = false;
$certStore = new CkCertStore();
// On MacOS and iOS, the OpenSmartcard method opens the Keychain.
// The argument passed to OpenSmartcard is ignored.
$success = $certStore->OpenSmartcard('');
if ($success == false) {
print $certStore->lastErrorText() . "\n";
exit;
}
$numCerts = $certStore->get_NumCertificates();
print 'numCerts = ' . $numCerts . "\n";
$cert = new CkCert();
$i = 0;
while ($i < $numCerts) {
// Note: Chilkat also gets the associated private key if it exists.
// You can simply use the cert in other places in Chilkat where a cert w/ private key is required.
$certStore->GetCert($i,$cert);
print $cert->subjectDN() . "\n";
print $cert->subjectCN() . "\n";
print $cert->serialNumber() . "\n";
if ($cert->IsRsa() == true) {
print 'key type is RSA' . "\n";
}
if ($cert->IsEcdsa() == true) {
print 'key type is ECDSA' . "\n";
}
print 'has private key: ' . $cert->HasPrivateKey() . "\n";
print '----' . "\n";
$i = $i + 1;
}
$certStore->CloseCertStore();
?>