Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PEM

Implements the PEM data encoding, which originated in Privacy Enhanced Mail. The most common use of PEM encoding today is in TLS keys and certificates. See RFC 1421.

A PEM represents a PEM encoded structure.

The encoded form is:

-----BEGIN Type-----
Headers
base64-encoded Bytes
-----END Type-----

Headers like:

Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,29DE8F99F382D122

Hierarchy

  • PEM

Index

Constructors

constructor

  • new PEM(type: string, body: Buffer): PEM
  • Parameters

    • type: string
    • body: Buffer

    Returns PEM

Properties

body

body: Buffer

The decoded bytes of the contents. Typically a DER encoded ASN.1 structure.

Private headers

headers: object

Type declaration

  • [index: string]: string

type

type: string

The type, taken from the preamble (i.e. "RSA PRIVATE KEY").

Accessors

procType

  • get procType(): string
  • Return exists Proc-Type header or empty string

    Returns string

Methods

Protected __computed

  • __computed(_depth: any, options: any): string
  • Parameters

    • _depth: any
    • options: any

    Returns string

getHeader

  • getHeader(key: string): string
  • Return a header or empty string with given key.

    Parameters

    • key: string

    Returns string

setHeader

  • setHeader(key: string, val: string): void
  • Set a header with given key/value.

    Parameters

    • key: string
    • val: string

    Returns void

toBuffer

  • toBuffer(): Buffer
  • Encode to PEM formatted buffer.

    Returns Buffer

toJSON

  • toJSON(): any
  • Return a friendly JSON object for debuging.

    Returns any

toString

  • toString(): string
  • Encode to PEM formatted string.

    Returns string

valueOf

  • valueOf(): Buffer
  • Returns the body.

    Returns Buffer

Static parse

  • parse(data: Buffer): PEM[]
  • Parse PEM formatted buffer, returns one or more PEM object. If there is no PEM object, it will throw error.

    Parameters

    • data: Buffer

      buffer to parse.

    Returns PEM[]

Generated using TypeDoc