doc: document TLS alpnProtocol and servername fields

Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64362
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Tim Perry authored and Antoine du Hamel committed 2026-08-06 15:35:07 +02:00
1 parent d66b7588ac
commit cbc2bed4e8
1 file changed
+29 -6
+29 -6
View File
@@ -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`
<!-- YAML
added: v6.0.0
-->
* 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`
<!-- YAML
@@ -1570,6 +1579,18 @@ When running as the server, the socket will be destroyed with an error after
For TLSv1.3, renegotiation cannot be initiated, it is not supported by the
protocol.
### `tlsSocket.servername`
<!-- YAML
added: v0.11.3
-->
* 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)`
<!-- YAML
@@ -2544,11 +2565,13 @@ added: v0.11.3
[`tls.DEFAULT_MAX_VERSION`]: #tlsdefault_max_version
[`tls.DEFAULT_MIN_VERSION`]: #tlsdefault_min_version
[`tls.Server`]: #class-tlsserver
[`tls.TLSSocket.alpnProtocol`]: #tlssocketalpnprotocol
[`tls.TLSSocket.enableTrace()`]: #tlssocketenabletrace
[`tls.TLSSocket.getPeerCertificate()`]: #tlssocketgetpeercertificatedetailed
[`tls.TLSSocket.getProtocol()`]: #tlssocketgetprotocol
[`tls.TLSSocket.getSession()`]: #tlssocketgetsession
[`tls.TLSSocket.getTLSTicket()`]: #tlssocketgettlsticket
[`tls.TLSSocket.servername`]: #tlssocketservername
[`tls.TLSSocket`]: #class-tlstlssocket
[`tls.connect()`]: #tlsconnectoptions-callback
[`tls.createSecureContext()`]: #tlscreatesecurecontextoptions