React Native
React Native
Get Certificate Policy
See more Certificates Examples
Demonstrates how to get a certificate's policy OIDs (if any)Chilkat React Native Downloads
import { Cert, Xml } from '@chilkat/react-native'
function chilkatExample() {
const cert = new Cert();
try {
cert.loadFromFile('qa_data/certs/sample.cer');
} catch {
console.log(cert.lastErrorText);
return;
}
// The certificatePolicies OID is 2.5.29.32
const oid = '2.5.29.32';
try {
const strXml = cert.getExtensionAsXml(oid);
console.log(strXml);
// Sample result:
// <sequence><sequence><oid>2.16.840.1.101.2.1.11.39</oid></sequence></sequence>
const xml = new Xml();
xml.loadXml(strXml);
console.log(`Policy OID = ${xml.getChildContent('sequence|oid')}`);
} catch {
// cert.getExtensionAsXml() failed; continue anyway.
}
}