Skip to main content

Server

class Server
extends net.Server

Accepts encrypted connections using TLS or SSL.

Constructors Jump to heading

new
Jump to headingServer(secureConnectionListener?: (socket: TLSSocket) => void)
new
Jump to headingServer(
options: TlsOptions,
secureConnectionListener?: (socket: TLSSocket) => void,
)
Jump to headingaddContext(
hostname: string,
): void

The server.addContext() method adds a secure context that will be used if the client request's SNI name matches the supplied hostname (or wildcard).

When there are multiple matching contexts, the most recently added one is used.

Jump to headingaddListener(
event: string,
listener: (...args: any[]) => void,
): this

events.EventEmitter

  1. tlsClientError
  2. newSession
  3. OCSPRequest
  4. resumeSession
  5. secureConnection
  6. keylog
Jump to headingaddListener(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingaddListener(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
Jump to headingaddListener(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
Jump to headingaddListener(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
Jump to headingaddListener(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
Jump to headingaddListener(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingemit(
event: string | symbol,
...args: any[],
): boolean
Jump to headingemit(
event: "tlsClientError",
err: Error,
tlsSocket: TLSSocket,
): boolean
Jump to headingemit(
event: "newSession",
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
): boolean
Jump to headingemit(
event: "OCSPRequest",
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
): boolean
Jump to headingemit(
event: "resumeSession",
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
): boolean
Jump to headingemit(
event: "secureConnection",
tlsSocket: TLSSocket,
): boolean
Jump to headingemit(
event: "keylog",
line: Buffer,
tlsSocket: TLSSocket,
): boolean

Returns the session ticket keys.

See Session Resumption for more information.

Jump to headingon(
event: string,
listener: (...args: any[]) => void,
): this
Jump to headingon(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingon(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
Jump to headingon(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
Jump to headingon(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
Jump to headingon(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
Jump to headingon(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingonce(
event: string,
listener: (...args: any[]) => void,
): this
Jump to headingonce(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingonce(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
Jump to headingonce(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
Jump to headingonce(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
Jump to headingonce(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
Jump to headingonce(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingprependListener(
event: string,
listener: (...args: any[]) => void,
): this
Jump to headingprependListener(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingprependListener(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
Jump to headingprependListener(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
Jump to headingprependListener(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
Jump to headingprependListener(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
Jump to headingprependListener(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingprependOnceListener(
event: string,
listener: (...args: any[]) => void,
): this
Jump to headingprependOnceListener(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
Jump to headingprependOnceListener(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
Jump to headingprependOnceListener(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
Jump to headingprependOnceListener(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
Jump to headingprependOnceListener(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
Jump to headingprependOnceListener(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this

The server.setSecureContext() method replaces the secure context of an existing server. Existing connections to the server are not interrupted.

Jump to headingsetTicketKeys(keys: Buffer): void

Sets the session ticket keys.

Changes to the ticket keys are effective only for future server connections. Existing or currently pending server connections will use the previous keys.

See Session Resumption for more information.

Back to top