Dart
Dart
Find Certificate by Serial Number
See more Cert Store Examples
Demonstrates how to find a certificate having the specified hexadecimal serial number.Note: Requires Chilkat v10.1.2 or later.
Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final certStore = CkCertStore();
// This example will search the certs on connected USB tokens and smartcards.
final argNotUsed = '';
try {
certStore.openSmartcard(argNotUsed);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
final hexSerial = '48FC93B46055948D36A7C98A89D69416';
final json = CkJsonObject();
json.updateString('serial', hexSerial);
final cert = CkCert();
try {
certStore.findCert(json, cert);
// Show the serial number and subject CN
print('Found: ${cert.serialNumber}, ${cert.subjectCN}');
} on ChilkatException {
print('Not found.');
}
}