Dart
Dart
Find Certificate by Subject CN (Common Name)
See more Cert Store Examples
Demonstrates how to find a certificate having the specified subject CN.Note: Requires Chilkat v10.1.2 or later.
Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final certStore = CkCertStore();
// This opens the Current User certificate store on Windows,
// On MacOS and iOS it opens the default Keychain.
final readOnly = false;
try {
certStore.openCurrentUserStore(readOnly);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Find the certificate having a Subject CN = "Example ABC".
final json = CkJsonObject();
json.updateString('CN', 'Example ABC');
final cert = CkCert();
try {
certStore.findCert(json, cert);
// Show the full distinguished name of the certificate.
print('Found: ${cert.subjectDN}');
} on ChilkatException {
print('Not found.');
}
}