Skip to content

Commit 11fb7ff

Browse files
committed
doc: document TLS alpnProtocol and servername fields
Signed-off-by: Tim Perry <pimterry@gmail.com>
1 parent f91697a commit 11fb7ff

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

doc/api/tls.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -741,12 +741,9 @@ server. If `tlsSocket.authorized` is `false`, then `socket.authorizationError`
741741
is set to describe how authorization failed. Depending on the settings
742742
of the TLS server, unauthorized connections may still be accepted.
743743

744-
The `tlsSocket.alpnProtocol` property is a string that contains the selected
745-
ALPN protocol. When ALPN has no selected protocol because the client or the
746-
server did not send an ALPN extension, `tlsSocket.alpnProtocol` equals `false`.
747-
748-
The `tlsSocket.servername` property is a string containing the server name
749-
requested via SNI.
744+
The [`tls.TLSSocket.servername`][] and [`tls.TLSSocket.alpnProtocol`][]
745+
properties can be used to check which server name was requested, and which
746+
protocol was negotiated.
750747

751748
### Event: `'tlsClientError'`
752749

@@ -1043,6 +1040,18 @@ Returns the bound `address`, the address `family` name, and `port` of the
10431040
underlying socket as reported by the operating system:
10441041
`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
10451042

1043+
### `tlsSocket.alpnProtocol`
1044+
1045+
<!-- YAML
1046+
added: v6.0.0
1047+
-->
1048+
1049+
* Type: {string|boolean|null}
1050+
1051+
The negotiated ALPN protocol. This is `null` before the handshake completes.
1052+
Once the handshake completes, it settles as either the negotiated protocol
1053+
name, or `false` if the peers did not negotiate an ALPN protocol.
1054+
10461055
### `tlsSocket.authorizationError`
10471056

10481057
<!-- YAML
@@ -1570,6 +1579,18 @@ When running as the server, the socket will be destroyed with an error after
15701579
For TLSv1.3, renegotiation cannot be initiated, it is not supported by the
15711580
protocol.
15721581

1582+
### `tlsSocket.servername`
1583+
1584+
<!-- YAML
1585+
added: v0.11.3
1586+
-->
1587+
1588+
* Type: {string|boolean|null}
1589+
1590+
The SNI (Server Name Indication) host name associated with the socket. This is
1591+
`null` before the handshake completes. Once the handshake completes it settles
1592+
as either the host name string, or `false` if SNI was not used.
1593+
15731594
### `tlsSocket.setKeyCert(context)`
15741595

15751596
<!-- YAML
@@ -2553,11 +2574,13 @@ added: v0.11.3
25532574
[`tls.DEFAULT_MAX_VERSION`]: #tlsdefault_max_version
25542575
[`tls.DEFAULT_MIN_VERSION`]: #tlsdefault_min_version
25552576
[`tls.Server`]: #class-tlsserver
2577+
[`tls.TLSSocket.alpnProtocol`]: #tlssocketalpnprotocol
25562578
[`tls.TLSSocket.enableTrace()`]: #tlssocketenabletrace
25572579
[`tls.TLSSocket.getPeerCertificate()`]: #tlssocketgetpeercertificatedetailed
25582580
[`tls.TLSSocket.getProtocol()`]: #tlssocketgetprotocol
25592581
[`tls.TLSSocket.getSession()`]: #tlssocketgetsession
25602582
[`tls.TLSSocket.getTLSTicket()`]: #tlssocketgettlsticket
2583+
[`tls.TLSSocket.servername`]: #tlssocketservername
25612584
[`tls.TLSSocket`]: #class-tlstlssocket
25622585
[`tls.connect()`]: #tlsconnectoptions-callback
25632586
[`tls.createSecureContext()`]: #tlscreatesecurecontextoptions

0 commit comments

Comments
 (0)