Encapsulates an X509 certificate and provides read-only access to its information.

    const { X509Certificate } = await import('crypto');

    const x509 = new X509Certificate('{... pem encoded cert ...}');

    console.log(x509.subject);

since

  v15.6.0

### Hierarchy

- X509Certificate

## Index

### Constructors

- constructor

### Properties

- ca
- fingerprint
- fingerprint256
- infoAccess
- issuer
- issuerCertificate
- keyUsage
- publicKey
- raw
- serialNumber
- subject
- subjectAltName
- validFrom
- validTo

### Methods

- checkEmail
- checkHost
- checkIP
- checkIssued
- checkPrivateKey
- toJSON
- toLegacyObject
- toString
- verify

## Constructors

### constructor

- new X509Certificate(buffer: BinaryLike): X509Certificate

- #### Parameters

  - ##### buffer: BinaryLike

  #### Returns X509Certificate

## Properties

### Readonly ca

ca: boolean

Will be `true` if this is a Certificate Authority (ca) certificate.

since

  v15.6.0

### Readonly fingerprint

fingerprint: string

The SHA-1 fingerprint of this certificate.

since

  v15.6.0

### Readonly fingerprint256

fingerprint256: string

The SHA-256 fingerprint of this certificate.

since

  v15.6.0

### Readonly infoAccess

infoAccess: string

The information access content of this certificate.

since

  v15.6.0

### Readonly issuer

issuer: string

The issuer identification included in this certificate.

since

  v15.6.0

### Optional Readonly issuerCertificate

issuerCertificate?: X509Certificate

The issuer certificate or `undefined` if the issuer certificate is not available.

since

  v15.9.0

### Readonly keyUsage

keyUsage: string[]

An array detailing the key usages for this certificate.

since

  v15.6.0

### Readonly publicKey

publicKey: <internal>.KeyObject

The public key `KeyObject` for this certificate.

since

  v15.6.0

### Readonly raw

raw: <internal>.Buffer

A `Buffer` containing the DER encoding of this certificate.

since

  v15.6.0

### Readonly serialNumber

serialNumber: string

The serial number of this certificate.

since

  v15.6.0

### Readonly subject

subject: string

The complete subject of this certificate.

since

  v15.6.0

### Readonly subjectAltName

subjectAltName: string

The subject alternative name specified for this certificate.

since

  v15.6.0

### Readonly validFrom

validFrom: string

The date/time from which this certificate is considered valid.

since

  v15.6.0

### Readonly validTo

validTo: string

The date/time until which this certificate is considered valid.

since

  v15.6.0

## Methods

### checkEmail

- checkEmail(email: string, options?: X509CheckOptions): string

- Checks whether the certificate matches the given email address.

  since

    v15.6.0

  #### Parameters

  - ##### email: string

  - ##### Optional options: X509CheckOptions

  #### Returns string

  Returns `email` if the certificate matches, `undefined` if it does not.

### checkHost

- checkHost(name: string, options?: X509CheckOptions): string

- Checks whether the certificate matches the given host name.

  since

    v15.6.0

  #### Parameters

  - ##### name: string

  - ##### Optional options: X509CheckOptions

  #### Returns string

  Returns `name` if the certificate matches, `undefined` if it does not.

### checkIP

- checkIP(ip: string, options?: X509CheckOptions): string

- Checks whether the certificate matches the given IP address (IPv4 or IPv6).

  since

    v15.6.0

  #### Parameters

  - ##### ip: string

  - ##### Optional options: X509CheckOptions

  #### Returns string

  Returns `ip` if the certificate matches, `undefined` if it does not.

### checkIssued

- checkIssued(otherCert: X509Certificate): boolean

- Checks whether this certificate was issued by the given `otherCert`.

  since

    v15.6.0

  #### Parameters

  - ##### otherCert: X509Certificate

  #### Returns boolean

### checkPrivateKey

- checkPrivateKey(privateKey: <internal>.KeyObject): boolean

- Checks whether the public key for this certificate is consistent with the given private key.

  since

    v15.6.0

  #### Parameters

  - ##### privateKey: <internal>.KeyObject

    A private key.

  #### Returns boolean

### toJSON

- toJSON(): string

- There is no standard JSON encoding for X509 certificates. The`toJSON()` method returns a string containing the PEM encoded certificate.

  since

    v15.6.0

  #### Returns string

### toLegacyObject

- toLegacyObject(): PeerCertificate

- Returns information about this certificate using the legacy `certificate object` encoding.

  since

    v15.6.0

  #### Returns PeerCertificate

### toString

- toString(): string

- Returns the PEM-encoded certificate.

  since

    v15.6.0

  #### Returns string

### verify

- verify(publicKey: <internal>.KeyObject): boolean

- Verifies that this certificate was signed by the given public key. Does not perform any other validation checks on the certificate.

  since

    v15.6.0

  #### Parameters

  - ##### publicKey: <internal>.KeyObject

    A public key.

  #### Returns boolean

Generated using TypeDoc