Dart Requires Chilkat v10.1.2+
Dart
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 Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final certStore = CkCertStore();
// On MacOS and iOS, the OpenSmartcard method opens the Keychain.
// The argument passed to OpenSmartcard is ignored.
try {
certStore.openSmartcard('');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final numCerts = certStore.numCertificates;
print('numCerts = $numCerts');
final cert = CkCert();
var 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);
print(cert.subjectCN);
print(cert.serialNumber);
if (cert.isRsa()) {
print('key type is RSA');
}
if (cert.isEcdsa()) {
print('key type is ECDSA');
}
print('has private key: ${cert.hasPrivateKey()}');
print('----');
i++;
}
certStore.closeCertStore();
}