node-oppenssl
    Preparing search index...

    Class OpenSSL

    Index

    Constructors

    Properties

    BufferSymbol: typeof BufferSymbol = ...
    PROXY: (Anonymous class) = ...

    Proxy that enables calling OpenSSL like a function: openssltemplate. Delegates to OpenSSL.exec()` and provides access to static properties.

    Accessors

    • get mime_types(): {
          ".ca.crt": string;
          ".cer": string;
          ".crl": string;
          ".crt": string;
          ".csr": string;
          ".key": string;
          ".p10": string;
          ".p12": string;
          ".p7b": string;
          ".p7c": string;
          ".p7r": string;
          ".p8": string;
          ".pem": string;
          ".pfx": string;
          ".pkix.crl": string;
          ".spc": string;
      }

      Exposes MIME type mappings for file extensions.

      Returns {
          ".ca.crt": string;
          ".cer": string;
          ".crl": string;
          ".crt": string;
          ".csr": string;
          ".key": string;
          ".p10": string;
          ".p12": string;
          ".p7b": string;
          ".p7c": string;
          ".p7r": string;
          ".p8": string;
          ".pem": string;
          ".pfx": string;
          ".pkix.crl": string;
          ".spc": string;
      }

    Methods

    • Analyzes PEM-formatted data to extract:

      • PEM type (e.g., "CERTIFICATE", "PRIVATE KEY")
      • Whether it contains a certificate chain (multiple certs)
      • Individual certificate blocks (if chain)

      Parameters

      • data: string | Buffer<ArrayBufferLike>

        PEM string or Buffer.

      Returns { certificates: never[] | RegExpMatchArray; isChain: boolean; type: string }

      Object with type, isChain, and certificates array.

    • Executes an OpenSSL command with automatic handling of Buffer arguments as temp files.

      • Buffers are written to temporary files in a unique working directory.
      • Command output (stdout) is captured as an OpenSSLBuffer.
      • Any generated files in the working dir (e.g., -out file.crt) are read and returned.
      • Working directory is cleaned up after execution.

      Parameters

      • args: any[]

        Command arguments; may include Buffers (treated as input files).

      • workdir: string | Promise<string> = ...

        Optional custom working directory (defaults to temp dir).

      Returns Promise<OpenSSLBuffer[] & { args: any[] }> & {
          one: () => Promise<OpenSSLBuffer>;
      }

      Promise resolving to array of OpenSSLBuffer results + metadata.

    • Initializes the OpenSSL wrapper by checking if openssl is available in PATH and parsing its version string into structured data.

      Exits process with helpful error if OpenSSL is missing.

      Returns Promise<void>

      Promise that resolves when version info is loaded.

    • Enhances a raw Buffer with OpenSSL-specific metadata and utilities:

      • Hashes (SHA1, SHA256, MD5) in base64url
      • PEM type detection (CERTIFICATE, PRIVATE KEY, etc.)
      • Certificate chain detection
      • MIME type
      • .toObject() for conversion to Node.js crypto KeyObject

      Parameters

      • b: Buffer

        Raw output buffer from OpenSSL command.

      • mimeType: string = 'application/octet-stream'

        Optional MIME type (defaults to octet-stream).

      Returns OpenSSLBuffer

      Enhanced OpenSSLBuffer instance.