Node.js module
tls
The 'node:tls' module provides an API for implementing TLS and SSL secure network communication. It wraps OpenSSL to create secure TCP connections via tls.createServer and tls.connect.
Features include certificate parsing, client authorization, secure context management, and TLS session resumption.
Works in Bun · notes
Core TLS/SSL functionality works. The deprecated `tls.createSecurePair` method is missing.
Functions 7
- tls.checkServerIdentity()
Verifies the certificate
certis issued tohostname. - tls.connect()
The
callbackfunction, if specified, will be added as a listener for the'secureConnect'event. - tls.createSecureContext()
createServersets the default value of thehonorCipherOrderoption totrue, other APIs that create secure contexts leave it unset. - tls.createServer()
Creates a new Server.
- tls.getCACertificates()
Returns an array containing the CA certificates from various sources, depending on
type. - tls.getCiphers()
Returns an array with the names of the supported TLS ciphers.
- tls.setDefaultCACertificates()
Sets the default CA certificates used by Node.js TLS clients.
Classes 2
- class tls.Server
Accepts encrypted connections using TLS or SSL.
- class tls.TLSSocket
Performs transparent encryption of written data and all required TLS negotiation.
Interfaces 17
- interface BunConnectionOptions
- interface Certificate
- interface CipherNameAndProtocol
- interface CommonConnectionOptions
- interface ConnectionOptions
- interface DetailedPeerCertificate
- interface EphemeralKeyInfo
- interface KeyObject
- interface PeerCertificate
- interface PSKCallbackNegotation
- interface PxfObject
- interface SecureContext
- interface SecureContextOptions
- interface ServerEventMap
- interface TlsOptions
- interface TLSSocketEventMap
- interface TLSSocketOptions
Types 1
Variables 7
- const tls.CLIENT_RENEG_LIMIT
- const tls.CLIENT_RENEG_WINDOW
- const tls.DEFAULT_CIPHERS
The default value of the
ciphersoption ofcreateSecureContext(). - const tls.DEFAULT_ECDH_CURVE
The default curve name to use for ECDH key agreement in a tls server.
- const tls.DEFAULT_MAX_VERSION
The default value of the
maxVersionoption ofcreateSecureContext(). - const tls.DEFAULT_MIN_VERSION
The default value of the
minVersionoption ofcreateSecureContext(). - const tls.rootCertificates
An immutable array of strings representing the root certificates (in PEM format) from the bundled Mozilla CA store as supplied by the current Node.js version.