PKI-Lite - v1.0.5
    Preparing search index...

    X.509 Certificate Revocation List (CRL) implementation.

    A CRL is a time-stamped list identifying revoked certificates that is signed by a CA. CRLs are used to check if a certificate has been revoked before relying on it. Each CRL has a validity period and contains information about when the next update will be available.

    CertificateList ::= SEQUENCE { tbsCertList TBSCertList, signatureAlgorithm AlgorithmIdentifier, signatureValue BIT STRING }

    // Create an empty CRL
    const crl = await CertificateList.createEmpty({
    issuer: caName,
    privateKey: caPrivateKey,
    signatureAlgorithmParams: { type: 'RSASSA_PKCS1_v1_5', params: { hash: 'SHA-256' } }
    })

    // Load CRL from PEM
    const crlFromPem = CertificateList.fromPem(pemString)

    // Fetch CRL from URL
    const crlFromUrl = await CertificateList.fetch('http://example.com/ca.crl')

    // Check if certificate is revoked
    const isRevoked = crl.tbsCertList.isRevoked(certificate.tbsCertificate.serialNumber)

    RFC 5280 Section 5 - CRL and CRL Extensions Profile

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    signatureAlgorithm: AlgorithmIdentifier

    Algorithm used to sign the CRL

    signatureValue: BitString

    Digital signature over the TBS CRL

    tbsCertList: TBSCertList

    The TBS (To Be Signed) portion of the CRL containing the revocation list

    Accessors

    • get pkiType(): string

      Gets the PKI type name for this object (typically the class name). Used for PEM headers and debugging output.

      Returns string

    Methods

    • Compares this PKI object with another for equality. Two objects are considered equal if their DER encodings are identical.

      Parameters

      • other: PkiBase<any>

        The other PKI object to compare with

      Returns boolean

      true if the objects are equal, false otherwise

    • Returns a human-readable string representation of this object. By default, returns the same as toString(), but subclasses can override for more user-friendly output.

      Returns string

      A human-readable string representation

    • Creates an empty CRL with no revoked certificates.

      This method is useful for initializing a new CRL or for testing purposes. The created CRL will have a validity period of 30 days by default.

      Parameters

      Returns Promise<CertificateList>

      Promise resolving to the created empty CRL

      const emptyCrl = await CertificateList.createEmpty({
      issuer: new Name({ commonName: 'Test CA' }),
      privateKey: caPrivateKey,
      signatureAlgorithmParams: {
      type: 'RSASSA_PKCS1_v1_5',
      params: { hash: 'SHA-384' }
      }
      })

      // CRL is valid for 30 days from creation
      console.log(emptyCrl.tbsCertList.thisUpdate) // Current time
      console.log(emptyCrl.tbsCertList.nextUpdate) // 30 days later
    • Fetches a CRL from a URL and parses it.

      This is commonly used to retrieve CRLs from Certificate Distribution Points specified in X.509 certificates.

      Parameters

      • url: string

        The URL to fetch the CRL from

      Returns Promise<CertificateList>

      Promise resolving to the fetched and parsed CRL

      Error if the HTTP request fails or CRL parsing fails

      // Fetch CRL from a CA's distribution point
      const crl = await CertificateList.fetch('http://crl.example.com/ca.crl')

      // Check certificate status
      const serialNumber = certificate.tbsCertificate.serialNumber
      if (crl.tbsCertList.isRevoked(serialNumber)) {
      console.log('Certificate is revoked')
      }
    • Creates a CertificateList from an ASN.1 structure.

      Parses the ASN.1 SEQUENCE structure and extracts the TBS certificate list, signature algorithm, and signature value components.

      Parameters

      Returns CertificateList

      The parsed CertificateList object

      Asn1ParseError if the ASN.1 structure is invalid

      const asn1 = derToAsn1(crlBytes)
      const crl = CertificateList.fromAsn1(asn1)
    • Creates a CertificateList from PEM-encoded text.

      Parameters

      • pem: string

        The PEM-encoded CRL string

      Returns CertificateList

      The parsed CertificateList

      Error if PEM parsing fails

      const pemCrl = `
      -----BEGIN X509 CRL-----
      MIIBzDCBtQIBATANBgkqhkiG9w0BAQsFADBeMQswCQYDVQQGEwJVUzELMAkGA1UE
      ...
      -----END X509 CRL-----`

      const crl = CertificateList.fromPem(pemCrl)