From f033d2a521e2f31e7a9ecfd24b4a32942a4f884f Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sun, 28 Jun 2020 09:50:10 +0200 Subject: [PATCH 1/2] doc: clarify that the ctx argument is optional Clarify that the `ctx` argument of the `SNICallback` callback is optional. Fixes: https://github.com/nodejs/node/issues/34085 --- doc/api/tls.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/api/tls.md b/doc/api/tls.md index a95a27c0af0b7d..871ed289b88810 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1696,12 +1696,16 @@ changes: * `sessionTimeout` {number} The number of seconds after which a TLS session created by the server will no longer be resumable. See [Session Resumption][] for more information. **Default:** `300`. - * `SNICallback(servername, cb)` {Function} A function that will be called if - the client supports SNI TLS extension. Two arguments will be passed when - called: `servername` and `cb`. `SNICallback` should invoke `cb(null, ctx)`, - where `ctx` is a `SecureContext` instance. (`tls.createSecureContext(...)` - can be used to get a proper `SecureContext`.) If `SNICallback` wasn't - provided the default callback with high-level API will be used (see below). + * `SNICallback(servername, callback)` {Function} A function that will be + called if the client supports SNI TLS extension. Two arguments will be + passed when called: `servername` and `callback`. `callback` is an + error-first callback that must be called synchronously and takes two + optional arguments: `error` and `ctx`. `ctx`, if provided, is a + `SecureContext` instance. [`tls.createSecureContext()`][] can be used to get + a proper `SecureContext`. If `callback` is called with a falsy `ctx` + argument, the default secure context of the server will be used. If + `SNICallback` wasn't provided the default callback with high-level API will + be used (see below). * `ticketKeys`: {Buffer} 48-bytes of cryptographically strong pseudo-random data. See [Session Resumption][] for more information. * `pskCallback` {Function} From 49afcba5b132a4e1af0662d96449fed124e31871 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sun, 28 Jun 2020 12:36:13 +0200 Subject: [PATCH 2/2] fixup! doc: clarify that the ctx argument is optional --- doc/api/tls.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/doc/api/tls.md b/doc/api/tls.md index 871ed289b88810..7cc52659103af0 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1699,13 +1699,12 @@ changes: * `SNICallback(servername, callback)` {Function} A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: `servername` and `callback`. `callback` is an - error-first callback that must be called synchronously and takes two - optional arguments: `error` and `ctx`. `ctx`, if provided, is a - `SecureContext` instance. [`tls.createSecureContext()`][] can be used to get - a proper `SecureContext`. If `callback` is called with a falsy `ctx` - argument, the default secure context of the server will be used. If - `SNICallback` wasn't provided the default callback with high-level API will - be used (see below). + error-first callback that takes two optional arguments: `error` and `ctx`. + `ctx`, if provided, is a `SecureContext` instance. + [`tls.createSecureContext()`][] can be used to get a proper `SecureContext`. + If `callback` is called with a falsy `ctx` argument, the default secure + context of the server will be used. If `SNICallback` wasn't provided the + default callback with high-level API will be used (see below). * `ticketKeys`: {Buffer} 48-bytes of cryptographically strong pseudo-random data. See [Session Resumption][] for more information. * `pskCallback` {Function}