Sample code for 30+ languages & platforms
Dart Requires Chilkat v10.1.2+

Apple Keychain - List Certificates

See more Apple Keychain Examples

Iterates over the certificates in the Apple Keychain.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final certStore = CkCertStore();

  // On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
  // The argument passed to OpenCurrentUserStore is ignored.
  try {
    certStore.openCurrentUserStore(false);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final numCerts = certStore.numCertificates;
  print('numCerts = $numCerts');

  final cert = CkCert();
  var i = 0;
  while (i < numCerts) {
    certStore.getCert(i, cert);
    print(cert.subjectDN);
    print(cert.subjectCN);
    print(cert.serialNumber);
    print('----');
    i++;
  }

  certStore.closeCertStore();
}