diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2019-01-30 12:18:04 -0800 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2019-02-01 19:06:58 -0800 |
commit | 0f8e8f7c6b9e7a8bdae53c831f37b2034d1c9fa7 (patch) | |
tree | 2b7d72ab24c8b9538e4e1da9a3fa5c71482fdb01 /lib/https.js | |
parent | e1aa9438ead2093a536e5981da7097c9196e7113 (diff) | |
download | android-node-v8-0f8e8f7c6b9e7a8bdae53c831f37b2034d1c9fa7.tar.gz android-node-v8-0f8e8f7c6b9e7a8bdae53c831f37b2034d1c9fa7.tar.bz2 android-node-v8-0f8e8f7c6b9e7a8bdae53c831f37b2034d1c9fa7.zip |
tls: introduce client 'session' event
OpenSSL has supported async notification of sessions and tickets since
1.1.0 using SSL_CTX_sess_set_new_cb(), for all versions of TLS. Using
the async API is optional for TLS1.2 and below, but for TLS1.3 it will
be mandatory. Future-proof applications should start to use async
notification immediately. In the future, for TLS1.3, applications that
don't use the async API will silently, but gracefully, fail to resume
sessions and instead do a full handshake.
See: https://wiki.openssl.org/index.php/TLS1.3#Sessions
PR-URL: https://github.com/nodejs/node/pull/25831
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Diffstat (limited to 'lib/https.js')
-rw-r--r-- | lib/https.js | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/https.js b/lib/https.js index 9ac4cfd0d3..041bd41edd 100644 --- a/lib/https.js +++ b/lib/https.js @@ -117,18 +117,20 @@ function createConnection(port, host, options) { } } - const socket = tls.connect(options, () => { - if (!options._agentKey) - return; + const socket = tls.connect(options); - this._cacheSession(options._agentKey, socket.getSession()); - }); - - // Evict session on error - socket.once('close', (err) => { - if (err) - this._evictSession(options._agentKey); - }); + if (options._agentKey) { + // Cache new session for reuse + socket.on('session', (session) => { + this._cacheSession(options._agentKey, session); + }); + + // Evict session on error + socket.once('close', (err) => { + if (err) + this._evictSession(options._agentKey); + }); + } return socket; } |