React Native
React Native
ZATCA Load Certificate and Private Key from PEM Files
See more ZATCA Examples
Demonstrates how to load a certificate and private key from a pair of PEM files.Chilkat React Native Downloads
import { Cert, PrivateKey } from '@chilkat/react-native'
function chilkatExample() {
// The LoadFromFile method will automatically detect the file format..
const cert = new Cert();
try {
cert.loadFromFile('qa_data/zatca/cert.pem');
} catch {
console.log(cert.lastErrorText);
return;
}
console.log(cert.subjectCN);
// Load the private key.
const privKey = new PrivateKey();
try {
privKey.loadPemFile('qa_data/zatca/ec-secp256k1-priv-key.pem');
} catch {
console.log(privKey.lastErrorText);
return;
}
console.log(`Key Type: ${privKey.keyType}`);
// Associate the private key with the certificate.
try {
cert.setPrivateKey(privKey);
} catch {
console.log(cert.lastErrorText);
return;
}
console.log('Success.');
}