From ed2d7f4528e6e78c62faba213b2a25c279a7da9d Mon Sep 17 00:00:00 2001 From: Tim Perry <1526883+pimterry@users.noreply.github.com> Date: Fri, 17 Jul 2026 11:35:56 +0200 Subject: [PATCH 1/6] doc: document TLS alpnProtocol and servername fields Signed-off-by: Tim Perry PR-URL: https://github.com/nodejs/node/pull/64362 Reviewed-By: Luigi Pinca --- doc/api/tls.md | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/doc/api/tls.md b/doc/api/tls.md index b02d9300c5f8bf..ae3de645eaa3b6 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -741,12 +741,9 @@ server. If `tlsSocket.authorized` is `false`, then `socket.authorizationError` is set to describe how authorization failed. Depending on the settings of the TLS server, unauthorized connections may still be accepted. -The `tlsSocket.alpnProtocol` property is a string that contains the selected -ALPN protocol. When ALPN has no selected protocol because the client or the -server did not send an ALPN extension, `tlsSocket.alpnProtocol` equals `false`. - -The `tlsSocket.servername` property is a string containing the server name -requested via SNI. +The [`tls.TLSSocket.servername`][] and [`tls.TLSSocket.alpnProtocol`][] +properties can be used to check which server name was requested, and which +protocol was negotiated. ### Event: `'tlsClientError'` @@ -1043,6 +1040,18 @@ Returns the bound `address`, the address `family` name, and `port` of the underlying socket as reported by the operating system: `{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`. +### `tlsSocket.alpnProtocol` + + + +* Type: {string|boolean|null} + +The negotiated ALPN protocol. This is `null` before the handshake completes. +Once the handshake completes, it settles as either the negotiated protocol +name, or `false` if the peers did not negotiate an ALPN protocol. + ### `tlsSocket.authorizationError` + +* Type: {string|boolean|null} + +The SNI (Server Name Indication) host name associated with the socket. This is +`null` before the handshake completes. Once the handshake completes it settles +as either the host name string, or `false` if SNI was not used. + ### `tlsSocket.setKeyCert(context)`