React Native
React Native
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat React Native Downloads
import { Cert, StringBuilder } from '@chilkat/react-native'
function chilkatExample() {
const cert = new Cert();
try {
cert.loadFromFile('C:/certs_and_keys/Certificate.cer');
} catch {
console.log(cert.lastErrorText);
return;
}
const sbPem = new StringBuilder();
try {
sbPem.loadFile('C:/certs_and_keys/PrivateKey.pem', 'utf-8');
} catch {
console.log('Failed to load private key PEM');
return;
}
try {
cert.setPrivateKeyPem(sbPem.getAsString());
} catch {
console.log(cert.lastErrorText);
return;
}
console.log('The certificate and associated private key are now loaded and ready for signing.');
}