Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TLSSocket

Hierarchy

Implements

Index

Constructors

constructor

Properties

Optional authorizationError

authorizationError: Error

Returns the reason why the peer's certificate was not been verified. This property is set only when tlsSocket.authorized === false.

authorized

authorized: boolean

Returns true if the peer certificate was signed by one of the CAs specified when creating the tls.TLSSocket instance, otherwise false.

bufferSize

bufferSize: number

bytesRead

bytesRead: number

bytesWritten

bytesWritten: number

encrypted

encrypted: true

Always returns true. This may be used to distinguish TLS sockets from regular net.Socket instances.

localAddress

localAddress: string

Returns the string representation of the local IP address.

localPort

localPort: number

Returns the numeric representation of the local port.

readable

readable: boolean

remoteAddress

remoteAddress: string

Returns the string representation of the remote IP address. For example, '74.125.127.100' or '2001:4860:a005::68'.

remoteFamily

remoteFamily: string

Returns the string representation of the remote IP family. 'IPv4' or 'IPv6'.

remotePort

remotePort: number

The numeric representation of the remote port. For example, 443.

writable

writable: boolean

Static EventEmitter

EventEmitter: EventEmitter

Static defaultMaxListeners

defaultMaxListeners: number

Methods

_read

  • _read(size: number): void

_write

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

addListener

  • addListener(event: string, listener: function)

address

  • address(): object

connect

  • connect(port: number, host?: string, connectionListener?: Function): void
  • connect(path: string, connectionListener?: Function): void

destroy

  • destroy(): void

emit

  • emit(event: string, ...args: any[]): boolean

end

  • end(): void
  • end(buffer: Buffer, cb?: Function): void
  • end(str: string, cb?: Function): void
  • end(str: string, encoding?: string, cb?: Function): void
  • end(data?: any, encoding?: string): void

eventNames

  • eventNames(): string[]

getCipher

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'.

    Returns EphemeralKeyInfo

getMaxListeners

  • getMaxListeners(): number

getPeerCertificate

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

    Parameters

    • Optional detailed: boolean

      Specify true to request that the full certificate chain with the issuer property be returned; false to return only the top certificate without the issuer property.

    Returns PeerCertificate

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.

    Returns string | null

getSession

  • getSession(): Buffer | undefined
  • Returns the ASN.1 encoded TLS session or undefined if no session was negotiated. Can be used to speed up handshake establishment when reconnecting to the server.

    Returns Buffer | undefined

getTLSTicket

  • getTLSTicket(): Buffer | undefined
  • Returns the TLS session ticket or undefined if no session was negotiated.

    Note: This only works with client TLS sockets. Useful only for debugging, for session reuse provide session option to tls.connect().

    Returns Buffer | undefined

isPaused

  • isPaused(): boolean

listenerCount

  • listenerCount(event: string): number

listeners

  • listeners(event: string): Array<function>

on

  • on(event: string, listener: function)

once

  • once(event: string, listener: function)

pause

  • pause()

pipe

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

prependListener

  • prependListener(event: string, listener: function)

prependOnceListener

  • prependOnceListener(event: string, listener: function)

push

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

read

  • read(size?: number): any

ref

  • ref(): void

removeAllListeners

  • removeAllListeners(event?: string)

removeListener

  • removeListener(event: string, listener: function)

renegotiate

  • The tlsSocket.renegotiate() method initiates a TLS renegotiation process.

    Note: This method can be used to request a peer's certificate after the secure connection has been established.

    Note: When running as the server, the socket will be destroyed with an error after handshakeTimeout timeout.

    Parameters

    • options: RenegotiateOptions
    • callback: function
        • (err: Error | null): any
        • Parameters

          • err: Error | null

          Returns any

    Returns any

resume

  • resume()

setDefaultEncoding

  • setDefaultEncoding(encoding: string)

setEncoding

  • setEncoding(encoding: string)

setKeepAlive

  • setKeepAlive(enable?: boolean, initialDelay?: number): void

setMaxListeners

  • setMaxListeners(n: number)

setMaxSendFragment

  • setMaxSendFragment(size: number): boolean
  • The tlsSocket.setMaxSendFragment() method sets the maximum TLS fragment size. Returns true if setting the limit succeeded; false otherwise.

    Smaller fragment sizes decrease the buffering latency on the client: larger 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

      The maximum TLS fragment size. Defaults to 16384. The maximum value is 16384.

    Returns boolean

setNoDelay

  • setNoDelay(noDelay?: boolean): void

setTimeout

  • setTimeout(timeout: number, callback?: Function): void

unpipe

  • unpipe<T>(destination?: T): void

unref

  • unref(): void

unshift

  • unshift(chunk: any): void

wrap

write

  • write(buffer: Buffer): boolean
  • write(buffer: Buffer, cb?: Function): boolean
  • write(str: string, cb?: Function): boolean
  • write(str: string, encoding?: string, cb?: Function): boolean
  • write(str: string, encoding?: string, fd?: string): boolean
  • write(data: any, encoding?: string, callback?: Function): void

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string): number

Generated using TypeDoc