Sample code for 30+ languages & platforms
React Native

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 React Native Downloads

React Native
import { Cert, CertStore, JsonObject } from '@chilkat/react-native'

function chilkatExample() {
  const certStore = new CertStore();

  // This opens the Current User certificate store on Windows,
  // On MacOS and iOS it opens the default Keychain.
  const readOnly = false;
  try {
    certStore.openCurrentUserStore(readOnly);
  } catch {
    console.log(certStore.lastErrorText);
    return;
  }

  // Find the certificate having a specific SHA1 thumbprint.
  const json = new JsonObject();
  const hexThumbprint = '767192374BE3C1512D2CB80734926D40E96D6DC2';
  json.updateString('thumbprint', hexThumbprint);

  const cert = new Cert();
  try {
    certStore.findCert(json, cert);
    // Show the full distinguished name of the certificate.
    console.log(`Found: ${cert.subjectDN}`);
  } catch {
    console.log('Not found.');
  }
}