Skip to main content
Server - node__tls.d.ts - Node documentation
class Server
extends net.Server

Usage in Deno

```typescript import { Server } from "node:node__tls.d.ts"; ```
Accepts encrypted connections using TLS or SSL.

Constructors

new
Server(secureConnectionListener?: (socket: TLSSocket) => void)
new
Server(
options: TlsOptions,
secureConnectionListener?: (socket: TLSSocket) => void,
)

Methods

addContext(
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.
addListener(
event: string,
listener: (...args: any[]) => void,
): this
events.EventEmitter 1. tlsClientError 2. newSession 3. OCSPRequest 4. resumeSession 5. secureConnection 6. keylog
addListener(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
addListener(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
addListener(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
addListener(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
addListener(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
addListener(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this
emit(
event: string | symbol,
...args: any[],
): boolean
emit(
event: "tlsClientError",
err: Error,
tlsSocket: TLSSocket,
): boolean
emit(
event: "newSession",
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
): boolean
emit(
event: "OCSPRequest",
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
): boolean
emit(
event: "resumeSession",
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
): boolean
emit(
event: "secureConnection",
tlsSocket: TLSSocket,
): boolean
emit(
event: "keylog",
line: Buffer,
tlsSocket: TLSSocket,
): boolean
getTicketKeys(): Buffer
Returns the session ticket keys. See `Session Resumption` for more information.
on(
event: string,
listener: (...args: any[]) => void,
): this
on(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
on(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
on(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
on(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
on(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
on(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this
once(
event: string,
listener: (...args: any[]) => void,
): this
once(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
once(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
once(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
once(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
once(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
once(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this
prependListener(
event: string,
listener: (...args: any[]) => void,
): this
prependListener(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
prependListener(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
prependListener(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
prependListener(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
prependListener(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
prependListener(
event: "keylog",
listener: (
line: Buffer,
tlsSocket: TLSSocket,
) => void
,
): this
prependOnceListener(
event: string,
listener: (...args: any[]) => void,
): this
prependOnceListener(
event: "tlsClientError",
listener: (
err: Error,
tlsSocket: TLSSocket,
) => void
,
): this
prependOnceListener(
event: "newSession",
listener: (
sessionId: Buffer,
sessionData: Buffer,
callback: () => void,
) => void
,
): this
prependOnceListener(
event: "OCSPRequest",
listener: (
certificate: Buffer,
issuer: Buffer,
callback: (
err: Error | null,
resp: Buffer,
) => void
,
) => void
,
): this
prependOnceListener(
event: "resumeSession",
listener: (
sessionId: Buffer,
callback: (
err: Error | null,
sessionData: Buffer | null,
) => void
,
) => void
,
): this
prependOnceListener(
event: "secureConnection",
listener: (tlsSocket: TLSSocket) => void,
): this
prependOnceListener(
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.
setTicketKeys(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.