Sample code for 30+ languages & platforms
React Native

Find Certificate by Subject O (Organization)

See more Cert Store Examples

Demonstrates how to find a certificate having the specified subject organization.

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 Subject O = "ICP-Brasil".
  const json = new JsonObject();
  const organization = 'ICP-Brasil';
  json.updateString('O', organization);

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