Skip to content
Permalink
Browse files

tls: do not confuse session and session ID

session ID was named session in C++ and key in JS, Name them after what
they are, as the 'newSession' event docs do.

PR-URL: #25153
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
  • Loading branch information...
sam-github authored and targos committed Dec 19, 2018
1 parent d5ba121 commit f6b2ea8bb9825bf585155fc58ed6d48e4a4b2929
Showing with 12 additions and 12 deletions.
  1. +2 −2 lib/_tls_wrap.js
  2. +10 −10 src/node_crypto.cc
@@ -212,7 +212,7 @@ function requestOCSPDone(socket) {
}


function onnewsession(key, session) {
function onnewsession(sessionId, session) {
const owner = this[owner_symbol];

if (!owner.server)
@@ -236,7 +236,7 @@ function onnewsession(key, session) {
};

owner._newSessionPending = true;
if (!owner.server.emit('newSession', key, session, done))
if (!owner.server.emit('newSession', sessionId, session, done))
done();
}

@@ -1483,20 +1483,20 @@ int SSLWrap<Base>::NewSessionCallback(SSL* s, SSL_SESSION* sess) {
return 0;

// Serialize session
Local<Object> buff = Buffer::New(env, size).ToLocalChecked();
unsigned char* serialized = reinterpret_cast<unsigned char*>(
Buffer::Data(buff));
memset(serialized, 0, size);
i2d_SSL_SESSION(sess, &serialized);
Local<Object> session = Buffer::New(env, size).ToLocalChecked();
unsigned char* session_data = reinterpret_cast<unsigned char*>(
Buffer::Data(session));
memset(session_data, 0, size);
i2d_SSL_SESSION(sess, &session_data);

unsigned int session_id_length;
const unsigned char* session_id = SSL_SESSION_get_id(sess,
&session_id_length);
Local<Object> session = Buffer::Copy(
const unsigned char* session_id_data = SSL_SESSION_get_id(sess,
&session_id_length);
Local<Object> session_id = Buffer::Copy(
env,
reinterpret_cast<const char*>(session_id),
reinterpret_cast<const char*>(session_id_data),
session_id_length).ToLocalChecked();
Local<Value> argv[] = { session, buff };
Local<Value> argv[] = { session_id, session };
w->new_session_wait_ = true;
w->MakeCallback(env->onnewsession_string(), arraysize(argv), argv);

0 comments on commit f6b2ea8

Please sign in to comment.
You can’t perform that action at this time.