TLS

tls.createSecureContext()

Builds reusable TLS configuration, such as certificate material and protocol bounds. A context alone does not establish a connection or verify a remote identity. Tested on Node.js 22.16.0. Example output (one line per entry): ["true"].

Formal Syntax & Structure

nodejs syntaxnodejs
tls.createSecureContext([options])

Parameters & Attributes

NameTypeDescription
optionsobjectTLS context configuration.

Return Value

SecureContext

TLS context.

Working Example

Example Snippetnodejs
import tls from 'node:tls';const context = tls.createSecureContext({ minVersion: 'TLSv1.2' });console.log(typeof context === 'object');
Node.js Reference