Sample code for 30+ languages & platforms
Dart

Find Certificate by SHA1 Thumbprint

See more Cert Store Examples

Demonstrates how to find a certificate having the specified hexadecimal SHA1 thumbprint.

Note: Requires Chilkat v10.1.2 or later.

Chilkat Dart Downloads

Dart
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 specific SHA1 thumbprint.
  final json = CkJsonObject();
  final hexThumbprint = '767192374BE3C1512D2CB80734926D40E96D6DC2';
  json.updateString('thumbprint', hexThumbprint);

  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.');
  }
}