summaryrefslogtreecommitdiff
path: root/src/node_crypto.cc
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2019-01-30 12:18:04 -0800
committerSam Roberts <vieuxtech@gmail.com>2019-02-01 19:06:58 -0800
commit0f8e8f7c6b9e7a8bdae53c831f37b2034d1c9fa7 (patch)
tree2b7d72ab24c8b9538e4e1da9a3fa5c71482fdb01 /src/node_crypto.cc
parente1aa9438ead2093a536e5981da7097c9196e7113 (diff)
downloadandroid-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 'src/node_crypto.cc')
-rw-r--r--src/node_crypto.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 9715e8b776..228dd0d16d 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -512,6 +512,7 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
// SSL session cache configuration
SSL_CTX_set_session_cache_mode(sc->ctx_.get(),
+ SSL_SESS_CACHE_CLIENT |
SSL_SESS_CACHE_SERVER |
SSL_SESS_CACHE_NO_INTERNAL |
SSL_SESS_CACHE_NO_AUTO_CLEAR);
@@ -1540,7 +1541,10 @@ int SSLWrap<Base>::NewSessionCallback(SSL* s, SSL_SESSION* sess) {
reinterpret_cast<const char*>(session_id_data),
session_id_length).ToLocalChecked();
Local<Value> argv[] = { session_id, session };
- w->awaiting_new_session_ = true;
+ // On servers, we pause the handshake until callback of 'newSession', which
+ // calls NewSessionDoneCb(). On clients, there is no callback to wait for.
+ if (w->is_server())
+ w->awaiting_new_session_ = true;
w->MakeCallback(env->onnewsession_string(), arraysize(argv), argv);
return 0;