Get started with PKI.js CDN
BSD-3-Clause licensed
Library: PKI.js - Lightweight PKI handling in browsers.
Tags:- ES6
- ES2015
- WebCrypto
- Web Cryptography API
- X.509
- certificate
- crl
- cms
- encrypted
- enveloped
- OCSP
- timestamp
- PKCS
Stable version
Copied!
How to start using PKI.js CDN
// Import PKI.js library
const PKI = await fetch('https://cdn.cdnhub.io/PKI.js/3.0.16/x509_simpl.min.js').then(res => res.arrayBuffer());
const pki = new Uint8Array(PKI.arrayBuffer());
PKI.load(pki);
// Load the X.509 certificate from a data URL
const certificateDataUrl = 'data:application/x-pki;base64,<BASE64_ENCODED_CERTIFICATE_DATA>';
const certificate = await fetch(certificateDataUrl)
.then(res => res.arrayBuffer())
.then(buf => PKI.parseCertificate(new Uint8Array(buf)));
// Perform certificate validation or verification using PKI.js methods
console.log(certificate.toPEM()); // Print the certificate in PEM format for debugging
console.log(certificate.isSelfSigned); // Check if the certificate is self-signed
console.log(certificate.isExpired); // Check if the certificate has expired
console.log(certificate.getNotBefore()); // Get the certificate's notBefore date
console.log(certificate.getNotAfter()); // Get the certificate's notAfter date