Sample code for 30+ languages & platforms
React Native

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

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

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

  // This example will search the certs on connected USB tokens and smartcards.
  const argNotUsed = '';
  try {
    certStore.openSmartcard(argNotUsed);
  } catch {
    console.log(certStore.lastErrorText);
    return;
  }

  // Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
  const hexSerial = '48FC93B46055948D36A7C98A89D69416';
  const json = new JsonObject();
  json.updateString('serial', hexSerial);

  const cert = new Cert();
  try {
    certStore.findCert(json, cert);
    // Show the serial number and subject CN
    console.log(`Found: ${cert.serialNumber}, ${cert.subjectCN}`);
  } catch {
    console.log('Not found.');
  }
}