Sample code for 30+ languages & platforms
React Native Requires Chilkat v10.1.2+

Load PFX/P12 File into Certificate Store Object

Demonstrates how to load a .pfx/.p12 into a certificate store object.

Chilkat React Native Downloads

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

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

  // This only loads the contents of the PFX file into the certStore object.
  // It is not importing the PFX into the Windows certificate stores.
  const pfxPassword = 'badssl.com';
  try {
    certStore.loadPfxFile('qa_data/pfx/badssl.com-client.p12', pfxPassword);
  } catch {
    console.log(certStore.lastErrorText);
    return;
  }

  // Examine each certificate (loaded from the PFX) in this certStore object
  const cert = new Cert();
  const numCerts = certStore.numCertificates;
  let i = 0;
  while (i < numCerts) {
    certStore.getCert(i, cert);
    console.log(`hasPrivateKey=${cert.hasPrivateKey()}, ${cert.subjectCN}`);
    i++;
  }
}