Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: clarify text about using 'session' event for compatibility #30746

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions doc/api/tls.md
Expand Up @@ -726,14 +726,12 @@ On the client, the `session` can be provided to the `session` option of

See [Session Resumption][] for more information.

Note: For TLSv1.2 and below, [`tls.TLSSocket.getSession()`][] can be called once
the handshake is complete. For TLSv1.3, only ticket based resumption is allowed
by the protocol, multiple tickets are sent, and the tickets aren't sent until
later, after the handshake completes, so it is necessary to wait for the
`'session'` event to get a resumable session. Applications are
recommended to use the `'session'` event instead of `getSession()` to ensure
they will work for all TLS protocol versions. Applications that only expect to
get or use 1 session should listen for this event only once:
For TLSv1.3, it is necessary to wait for the 'session' event to get a resumable
session. This is because only ticket-based resumption is allowed by the
protocol. Tickets aren't sent until after the handshake completes. Applications
Trott marked this conversation as resolved.
Show resolved Hide resolved
should use the 'session' event instead of [`tls.TLSSocket.getSession()`][] to
Trott marked this conversation as resolved.
Show resolved Hide resolved
ensure they work for all TLS versions. Applications that only expect to get or
use 1 session should listen for this event only once:

```js
tlsSocket.once('session', (session) => {
Expand Down