React Native
React Native
Load PFX/P12 from a Base64 Encoded PFX File
See more PFX/P12 Examples
Demonstrates how to call LoadPfxEncoded.Chilkat React Native Downloads
import { BinData, Pfx } from '@chilkat/react-native'
function chilkatExample() {
const bd = new BinData();
try {
bd.loadFile('qa_data/pfx/cert_test123.pfx');
} catch {
console.log('Failed to load PFX file.');
return;
}
// Get the bytes contained in the PFX in base64 format:
const strBase64 = bd.getEncoded('base64');
// The base64 looks like this: "MIIbEAIBAzCCGswGCSqGSIb3DQEHAaCCGr0Eghq5MIIatTCCBg..."
console.log(strBase64);
const pfx = new Pfx();
// Load the PFX from the base64 string
const password = 'test123';
try {
pfx.loadPfxEncoded(strBase64, 'base64', password);
} catch {
console.log(pfx.lastErrorText);
return;
}
console.log('success');
}