method

quic.QuicEndpoint.setSNIContexts

entries: Record<string, SNIEntry>,
): void;

Replaces or updates the SNI TLS contexts for this endpoint. This allows changing the TLS identity (key/certificate) used for specific host names without restarting the endpoint. Existing sessions are unaffected — only new sessions will use the updated contexts.

endpoint.setSNIContexts({
  'api.example.com': { keys: [newApiKey], certs: [newApiCert] },
});

// Replace the entire SNI map
endpoint.setSNIContexts({
  'api.example.com': { keys: [newApiKey], certs: [newApiCert] },
}, { replace: true });
@param entries

An object mapping host names to TLS identity options. Each entry must include keys and certs.

Referenced types

interface SNIEntry

  • authoritative?: boolean

    Whether to include this host name in ORIGIN frames. Default: true. Set to false to exclude a host name from ORIGIN advertisements. Wildcard ('*') entries are always excluded regardless of this setting.

  • certs: ArrayBuffer | ArrayBufferView<ArrayBufferLike> | readonly unknown[]

    The TLS certificates. Required.

  • keys: KeyObject | readonly KeyObject[]

    The TLS private keys. Required.

  • port?: number

    The port to advertise in ORIGIN frames (RFC 9412) for this host name. Default: 443. Only used for HTTP/3 sessions.

  • verifyPrivateKey?: boolean

    Verify the private key. Default: false.

interface SetSNIContextsOptions