Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

Properties

Optional alpnProtocol

alpnProtocol: 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
deprecated

since v14.6.0 - Use writableLength instead.

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

readableEncoding

readableEncoding: BufferEncoding | null

readableEnded

readableEnded: boolean

readableFlowing

readableFlowing: boolean | null

readableHighWaterMark

readableHighWaterMark: number

readableLength

readableLength: number

readableObjectMode

readableObjectMode: boolean

Optional remoteAddress

remoteAddress: string

Optional remoteFamily

remoteFamily: string

Optional remotePort

remotePort: number

writable

writable: boolean

writableCorked

writableCorked: number

writableEnded

writableEnded: boolean

writableFinished

writableFinished: boolean

writableHighWaterMark

writableHighWaterMark: number

writableLength

writableLength: number

writableObjectMode

writableObjectMode: boolean

Methods

[Symbol.asyncIterator]

_destroy

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

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

          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: BufferEncoding, callback: function): void
  • Parameters

    • chunk: any
    • encoding: BufferEncoding
    • 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
        • Parameters

          Returns void

    Returns this

  • Parameters

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

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function

    Returns this

address

connect

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

    • options: SocketConnectOpts
    • Optional connectionListener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • port: number
    • host: string
    • Optional connectionListener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • port: number
    • Optional connectionListener: function
        • (): void
        • Returns void

    Returns this

  • Parameters

    • path: string
    • Optional connectionListener: function
        • (): void
        • Returns void

    Returns this

cork

  • cork(): void
  • Returns void

destroy

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

    Returns void

disableRenegotiation

  • disableRenegotiation(): void
  • Disables TLS renegotiation for this TLSSocket instance. Once called, attempts to renegotiate will trigger an 'error' event on the TLSSocket.

    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?: function): void
  • end(buffer: Uint8Array | string, cb?: function): void
  • end(str: Uint8Array | string, encoding?: BufferEncoding, cb?: function): void
  • Parameters

    • Optional cb: function
        • (): void
        • Returns void

    Returns void

  • Parameters

    • buffer: Uint8Array | string
    • Optional cb: function
        • (): void
        • Returns void

    Returns void

  • Parameters

    • str: Uint8Array | string
    • Optional encoding: BufferEncoding
    • Optional cb: function
        • (): void
        • Returns void

    Returns void

eventNames

  • eventNames(): Array<string | symbol>

exportKeyingMaterial

  • exportKeyingMaterial(length: number, label: string, context: Buffer): Buffer
  • Parameters

    • length: number

      number of bytes to retrieve from keying material

    • label: string

      an application specific label, typically this will be a value from the IANA Exporter Label Registry.

    • context: Buffer

      optionally provide a context.

    Returns Buffer

getCertificate

  • Returns an object representing the local certificate. The returned object has some properties corresponding to the fields of the certificate.

    See tls.TLSSocket.getPeerCertificate() for an example of the certificate structure.

    If there is no local certificate, an empty object will be returned. If the socket has been destroyed, null will be returned.

    Returns PeerCertificate | object | null

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.

getEphemeralKeyInfo

  • Returns an object representing the type, name, and size of parameter of an ephemeral key exchange in Perfect Forward Secrecy on a client connection. It returns an empty object when the key exchange is not ephemeral. As this is only supported on a client socket; null is returned if called on a server socket. The supported types are 'DH' and 'ECDH'. The name property is available only when type is 'ECDH'.

    For example: { type: 'ECDH', name: 'prime256v1', size: 256 }.

    Returns EphemeralKeyInfo | object | null

getFinished

  • getFinished(): Buffer | undefined
  • Returns the latest Finished message that has been sent to the socket as part of a SSL/TLS handshake, or undefined if no Finished message has been sent yet.

    As the Finished messages are message digests of the complete handshake (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can be used for external authentication procedures when the authentication provided by SSL/TLS is not desired or is not enough.

    Corresponds to the SSL_get_finished routine in OpenSSL and may be used to implement the tls-unique channel binding from RFC 5929.

    Returns Buffer | undefined

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: false

    Returns PeerCertificate

  • Parameters

    • Optional detailed: boolean

    Returns PeerCertificate | DetailedPeerCertificate

getPeerFinished

  • getPeerFinished(): Buffer | undefined
  • Returns the latest Finished message that is expected or has actually been received from the socket as part of a SSL/TLS handshake, or undefined if there is no Finished message so far.

    As the Finished messages are message digests of the complete handshake (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can be used for external authentication procedures when the authentication provided by SSL/TLS is not desired or is not enough.

    Corresponds to the SSL_get_peer_finished routine in OpenSSL and may be used to implement the tls-unique channel binding from RFC 5929.

    Returns Buffer | undefined

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.

getSharedSigalgs

  • getSharedSigalgs(): string[]
  • Returns a list of signature algorithms shared between the server and the client in the order of decreasing preference.

    Returns string[]

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

isSessionReused

  • isSessionReused(): boolean
  • Returns true if the session was reused, false otherwise.

    Returns boolean

listenerCount

  • listenerCount(event: 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
        • Parameters

          Returns void

    Returns this

  • Parameters

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

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function

    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
        • Parameters

          Returns void

    Returns this

  • Parameters

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

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function

    Returns this

pause

  • pause(): this

pipe

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

    Parameters

    • destination: T
    • Optional options: object
      • Optional end?: boolean

    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
        • Parameters

          Returns void

    Returns this

  • Parameters

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

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function

    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
        • Parameters

          Returns void

    Returns this

  • Parameters

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

    Returns this

  • Parameters

    • event: "session"
    • listener: function
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "keylog"
    • listener: function

    Returns this

push

  • Parameters

    Returns boolean

rawListeners

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

read

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

    • Optional size: number

    Returns any

ref

  • ref(): this
  • Returns this

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: "error", listener: function): this
  • removeListener(event: "pause", listener: function): this
  • removeListener(event: "readable", listener: function): this
  • removeListener(event: "resume", 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?: boolean
      • Optional requestCert?: boolean
    • callback: function

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

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

          Returns void

    Returns undefined | boolean

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

resume

  • resume(): this

setDefaultEncoding

setEncoding

setKeepAlive

  • setKeepAlive(enable?: boolean, initialDelay?: number): this
  • Parameters

    • Optional enable: boolean
    • Optional initialDelay: 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?: boolean): this
  • Parameters

    • Optional noDelay: boolean

    Returns this

setTimeout

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

    • timeout: number
    • Optional callback: function
        • (): void
        • Returns void

    Returns this

uncork

  • uncork(): void
  • Returns void

unpipe

unref

  • unref(): this
  • Returns this

unshift

  • Parameters

    Returns void

wrap

write

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

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

          Returns void

    Returns boolean

  • Parameters

    • str: Uint8Array | string
    • Optional encoding: BufferEncoding
    • Optional cb: function
        • Parameters

          Returns void

    Returns boolean

Static from

  • A utility method for creating Readable Streams out of iterators.

    Parameters

    Returns Readable

Generated using TypeDoc