webcrypto.dev-examples

Overview

pkijs is a low level Typescript library that provides support for working with X.509 certificates and related data structures. Chances are you should be using @peculiar/x509 instead.

npm npm (scoped)

Samples

Sample Description
Creating an X509 Certificate Demonstrates how to create a self-signed certificate for document signing, with a validity of 1 year.
Reading an X509 Certificate Demonstrates how to parse and retrieve information from a BASE64-encoded X.509 certificate.
Creating a PKCS10 Certificate Signing Request Demonstrates how to create a PKCS10 certificate request with SubjectAlternativeName and ChallengePassword and output the byte set in ASN.1 encoding.
Creating a Certificate Revocation List (CRL) Demonstrates how to create a CRL with two revoked certificates and encode the result into a byte set in ASN.1 format.
Creating an OCSP Request Demonstrates how to create an OCSP request for a specified certificate and encode the result into a byte set in ASN.1 format.
Reading an OCSP Response Demonstrates how to read an OCSP response and verify the status for a given certificate.
CMS Signed Data, sign without signedAttributes, data included Demonstrates how to create a CMS SignedData object with a detached signature, but without including any signed attributes in the signature.
CMS Signed Data, sign with signedAttributes, detached Demonstrates how to create a CMS SignedData object with a detached signature, and including signed attributes in the signature.
Verifying a Signature of CMS SignedData Demonstrates how to verify a CMS SignedData
Verifying a Detached Signature of CMS SignedData Demonstrates how to verify a CMS SignedData with a detached signature
Encrypt data using RSA private key Demonstrates how to encrypt a message using the recipient’s public key and save the data in CMS EnvelopedData format.
Decrypt data using RSA public key Demonstrates how to read encrypted data from CMS EnvelopedData, decrypt it using the recipient’s RSA-OAEP private key.
Chain building Demonstrates how to build and verify a certificate chain using a list of certificates and a list of certificate revocations.