React Native
React Native
Import a Certificate (.cer file) into a Windows Certificate Store
See more Certificates Examples
Demonstrates how to import a certificate (without private key) into a Windows certificate store.Chilkat React Native Downloads
import { Cert, CertStore } from '@chilkat/react-native'
function chilkatExample() {
const cert = new Cert();
try {
cert.loadFromFile('qa_data/certs/example.cer');
} catch {
console.log(cert.lastErrorText);
return;
}
const certStoreCU = new CertStore();
const readOnlyFlag = false;
// "CurrentUser" and "My" are the exact keywords to select your user account's certificate store.
try {
certStoreCU.openWindowsStore('CurrentUser', 'My', readOnlyFlag);
} catch {
console.log('Failed to open the CurrentUser/My certificate store for read/write.');
return;
}
// Import the certificate into the CurrentUser/My certificate store.
try {
certStoreCU.addCertificate(cert);
} catch {
console.log(certStoreCU.lastErrorText);
return;
}
console.log(`Imported ${cert.subjectCN}`);
console.log('Success.');
}