Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

Properties

Optional alpnProtocol

alpnProtocol: undefined | string

String containing the selected ALPN protocol. When ALPN has no selected protocol, tlsSocket.alpnProtocol equals false.

authorizationError

authorizationError: Error

The reason why the peer's certificate has not been verified. This property becomes available only when tlsSocket.authorized === false.

authorized

authorized: boolean

A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.

bufferSize

bufferSize: number

bytesRead

bytesRead: number

bytesWritten

bytesWritten: number

connecting

connecting: boolean

destroyed

destroyed: boolean

encrypted

encrypted: boolean

Static boolean value, always true. May be used to distinguish TLS sockets from regular ones.

localAddress

localAddress: string

localPort

localPort: number

readable

readable: boolean

readableHighWaterMark

readableHighWaterMark: number

readableLength

readableLength: number

Optional remoteAddress

remoteAddress: undefined | string

Optional remoteFamily

remoteFamily: undefined | string

Optional remotePort

remotePort: undefined | number

writable

writable: boolean

writableFinished

writableFinished: boolean

writableHighWaterMark

writableHighWaterMark: number

writableLength

writableLength: number

Static defaultMaxListeners

defaultMaxListeners: number

Methods

__@asyncIterator

_destroy

  • _destroy(error: Error | null, callback: function): void
  • Parameters

    • error: Error | null
    • callback: function
        • (error: Error | null): void
        • Parameters

          • error: Error | null

          Returns void

    Returns void

_final

  • _final(callback: function): void
  • Parameters

    • callback: function
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

_read

  • _read(size: number): void
  • Parameters

    • size: number

    Returns void

_write

  • _write(chunk: any, encoding: string, callback: function): void
  • Parameters

    • chunk: any
    • encoding: string
    • callback: function
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

Optional _writev

  • _writev(chunks: Array<object>, callback: function): void
  • Parameters

    • chunks: Array<object>
    • callback: function
        • (error?: Error | null): void
        • Parameters

          • Optional error: Error | null

          Returns void

    Returns void

addListener

  • addListener(event: string, listener: function): this
  • addListener(event: "OCSPResponse", listener: function): this
  • addListener(event: "secureConnect", listener: function): this
  • addListener(event: "session", listener: function): this
  • addListener(event: "keylog", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "OCSPResponse"
    • listener: function
        • (response: Buffer): void
        • Parameters

          • response: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "secureConnect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • (session: Buffer): void
        • Parameters

          • session: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function
        • (line: Buffer): void
        • Parameters

          • line: Buffer

          Returns void

    Returns this

address

connect

  • connect(options: SocketConnectOpts, connectionListener?: undefined | function): this
  • connect(port: number, host: string, connectionListener?: undefined | function): this
  • connect(port: number, connectionListener?: undefined | function): this
  • connect(path: string, connectionListener?: undefined | function): this
  • Parameters

    Returns this

  • Parameters

    • port: number
    • host: string
    • Optional connectionListener: undefined | function

    Returns this

  • Parameters

    • port: number
    • Optional connectionListener: undefined | function

    Returns this

  • Parameters

    • path: string
    • Optional connectionListener: undefined | function

    Returns this

cork

  • cork(): void
  • Returns void

destroy

  • destroy(error?: Error): void
  • Parameters

    Returns void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • emit(event: "OCSPResponse", response: Buffer): boolean
  • emit(event: "secureConnect"): boolean
  • emit(event: "session", session: Buffer): boolean
  • emit(event: "keylog", line: Buffer): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

  • Parameters

    • event: "OCSPResponse"
    • response: Buffer

    Returns boolean

  • Parameters

    • event: "secureConnect"

    Returns boolean

  • Parameters

    • event: "session"
    • session: Buffer

    Returns boolean

  • Parameters

    • event: "keylog"
    • line: Buffer

    Returns boolean

enableTrace

  • enableTrace(): void
  • When enabled, TLS packet trace information is written to stderr. This can be used to debug TLS connection problems.

    Note: The format of the output is identical to the output of openssl s_client -trace or openssl s_server -trace. While it is produced by OpenSSL's SSL_trace() function, the format is undocumented, can change without notice, and should not be relied on.

    Returns void

end

  • end(cb?: undefined | function): void
  • end(buffer: Uint8Array | string, cb?: undefined | function): void
  • end(str: Uint8Array | string, encoding?: undefined | string, cb?: undefined | function): void
  • Parameters

    • Optional cb: undefined | function

    Returns void

  • Parameters

    • buffer: Uint8Array | string
    • Optional cb: undefined | function

    Returns void

  • Parameters

    • str: Uint8Array | string
    • Optional encoding: undefined | string
    • Optional cb: undefined | function

    Returns void

eventNames

  • eventNames(): Array<string | symbol>

getCipher

  • Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.

    Returns CipherNameAndProtocol

    Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.

getMaxListeners

  • getMaxListeners(): number

getPeerCertificate

  • Returns an object representing the peer's certificate. The returned object has some properties corresponding to the field of the certificate. If detailed argument is true the full chain with issuer property will be returned, if false only the top certificate without issuer property. If the peer does not provide a certificate, it returns null or an empty object.

    Parameters

    • detailed: true

      If true; the full chain with issuer property will be returned.

    Returns DetailedPeerCertificate

    An object representing the peer's certificate.

  • Parameters

    • Optional detailed: undefined | false

    Returns PeerCertificate

  • Parameters

    • Optional detailed: undefined | false | true

    Returns PeerCertificate | DetailedPeerCertificate

getProtocol

  • getProtocol(): string | null
  • Returns a string containing the negotiated SSL/TLS protocol version of the current connection. The value 'unknown' will be returned for connected sockets that have not completed the handshaking process. The value null will be returned for server sockets or disconnected client sockets. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_get_version.html for more information.

    Returns string | null

    negotiated SSL/TLS protocol version of the current connection

getSession

  • getSession(): Buffer | undefined
  • Could be used to speed up handshake establishment when reconnecting to the server.

    Returns Buffer | undefined

    ASN.1 encoded TLS session or undefined if none was negotiated.

getTLSTicket

  • getTLSTicket(): Buffer | undefined
  • NOTE: Works only with client TLS sockets. Useful only for debugging, for session reuse provide session option to tls.connect().

    Returns Buffer | undefined

    TLS session ticket or undefined if none was negotiated.

isPaused

  • isPaused(): boolean

listenerCount

  • listenerCount(type: string | symbol): number

listeners

  • listeners(event: string | symbol): Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string, listener: function): this
  • on(event: "OCSPResponse", listener: function): this
  • on(event: "secureConnect", listener: function): this
  • on(event: "session", listener: function): this
  • on(event: "keylog", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "OCSPResponse"
    • listener: function
        • (response: Buffer): void
        • Parameters

          • response: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "secureConnect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • (session: Buffer): void
        • Parameters

          • session: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function
        • (line: Buffer): void
        • Parameters

          • line: Buffer

          Returns void

    Returns this

once

  • once(event: string, listener: function): this
  • once(event: "OCSPResponse", listener: function): this
  • once(event: "secureConnect", listener: function): this
  • once(event: "session", listener: function): this
  • once(event: "keylog", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "OCSPResponse"
    • listener: function
        • (response: Buffer): void
        • Parameters

          • response: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "secureConnect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • (session: Buffer): void
        • Parameters

          • session: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function
        • (line: Buffer): void
        • Parameters

          • line: Buffer

          Returns void

    Returns this

pause

  • pause(): this

pipe

  • pipe<T>(destination: T, options?: undefined | object): T
  • Type parameters

    Parameters

    • destination: T
    • Optional options: undefined | object

    Returns T

prependListener

  • prependListener(event: string, listener: function): this
  • prependListener(event: "OCSPResponse", listener: function): this
  • prependListener(event: "secureConnect", listener: function): this
  • prependListener(event: "session", listener: function): this
  • prependListener(event: "keylog", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "OCSPResponse"
    • listener: function
        • (response: Buffer): void
        • Parameters

          • response: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "secureConnect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • (session: Buffer): void
        • Parameters

          • session: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function
        • (line: Buffer): void
        • Parameters

          • line: Buffer

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string, listener: function): this
  • prependOnceListener(event: "OCSPResponse", listener: function): this
  • prependOnceListener(event: "secureConnect", listener: function): this
  • prependOnceListener(event: "session", listener: function): this
  • prependOnceListener(event: "keylog", listener: function): this
  • Parameters

    • event: string
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "OCSPResponse"
    • listener: function
        • (response: Buffer): void
        • Parameters

          • response: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "secureConnect"
    • listener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • (session: Buffer): void
        • Parameters

          • session: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function
        • (line: Buffer): void
        • Parameters

          • line: Buffer

          Returns void

    Returns this

push

  • push(chunk: any, encoding?: undefined | string): boolean
  • Parameters

    • chunk: any
    • Optional encoding: undefined | string

    Returns boolean

rawListeners

  • rawListeners(event: string | symbol): Function[]

read

  • read(size?: undefined | number): any
  • Parameters

    • Optional size: undefined | number

    Returns any

ref

  • ref(): void
  • Returns void

removeAllListeners

  • removeAllListeners(event?: string | symbol): this

removeListener

  • removeListener(event: "close", listener: function): this
  • removeListener(event: "data", listener: function): this
  • removeListener(event: "end", listener: function): this
  • removeListener(event: "readable", listener: function): this
  • removeListener(event: "error", listener: function): this
  • removeListener(event: string | symbol, listener: function): this

renegotiate

  • renegotiate(options: object, callback: function): undefined | boolean
  • Initiate TLS renegotiation process.

    NOTE: Can be used to request peer's certificate after the secure connection has been established. ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.

    Parameters

    • options: object

      The options may contain the following fields: rejectUnauthorized, requestCert (See tls.createServer() for details).

      • Optional rejectUnauthorized?: undefined | false | true
      • Optional requestCert?: undefined | false | true
    • callback: function

      callback(err) will be executed with null as err, once the renegotiation is successfully completed.

        • (err: Error | null): void
        • Parameters

          • err: Error | null

          Returns void

    Returns undefined | boolean

    undefined when socket is destroy, false if negotiaion can't be initiated.

resume

  • resume(): this

setDefaultEncoding

  • setDefaultEncoding(encoding: string): this
  • Parameters

    • encoding: string

    Returns this

setEncoding

  • setEncoding(encoding?: undefined | string): this

setKeepAlive

  • setKeepAlive(enable?: undefined | false | true, initialDelay?: undefined | number): this
  • Parameters

    • Optional enable: undefined | false | true
    • Optional initialDelay: undefined | number

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this

setMaxSendFragment

  • setMaxSendFragment(size: number): boolean
  • Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512). Smaller fragment size decreases buffering latency on the client: large fragments are buffered by the TLS layer until the entire fragment is received and its integrity is verified; large fragments can span multiple roundtrips, and their processing can be delayed due to packet loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, which may decrease overall server throughput.

    Parameters

    • size: number

      TLS fragment size (default and maximum value is: 16384, minimum is: 512).

    Returns boolean

    Returns true on success, false otherwise.

setNoDelay

  • setNoDelay(noDelay?: undefined | false | true): this
  • Parameters

    • Optional noDelay: undefined | false | true

    Returns this

setTimeout

  • setTimeout(timeout: number, callback?: undefined | function): this
  • Parameters

    • timeout: number
    • Optional callback: undefined | function

    Returns this

uncork

  • uncork(): void
  • Returns void

unpipe

unref

  • unref(): void
  • Returns void

unshift

  • Parameters

    Returns void

wrap

write

  • write(buffer: Uint8Array | string, cb?: undefined | function): boolean
  • write(str: Uint8Array | string, encoding?: undefined | string, cb?: undefined | function): boolean
  • Parameters

    • buffer: Uint8Array | string
    • Optional cb: undefined | function

    Returns boolean

  • Parameters

    • str: Uint8Array | string
    • Optional encoding: undefined | string
    • Optional cb: undefined | function

    Returns boolean

Static from

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    Returns number

Generated using TypeDoc