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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Sam Roberts 2018-12-19 14:45:51 -08:00
parent b50c22a904
commit 03e23a3d10
2 changed files with 12 additions and 12 deletions

View File

@ -214,7 +214,7 @@ function requestOCSPDone(socket) {
} }
function onnewsession(key, session) { function onnewsession(sessionId, session) {
const owner = this[owner_symbol]; const owner = this[owner_symbol];
if (!owner.server) if (!owner.server)
@ -238,7 +238,7 @@ function onnewsession(key, session) {
}; };
owner._newSessionPending = true; owner._newSessionPending = true;
if (!owner.server.emit('newSession', key, session, done)) if (!owner.server.emit('newSession', sessionId, session, done))
done(); done();
} }

View File

@ -1510,20 +1510,20 @@ int SSLWrap<Base>::NewSessionCallback(SSL* s, SSL_SESSION* sess) {
return 0; return 0;
// Serialize session // Serialize session
Local<Object> buff = Buffer::New(env, size).ToLocalChecked(); Local<Object> session = Buffer::New(env, size).ToLocalChecked();
unsigned char* serialized = reinterpret_cast<unsigned char*>( unsigned char* session_data = reinterpret_cast<unsigned char*>(
Buffer::Data(buff)); Buffer::Data(session));
memset(serialized, 0, size); memset(session_data, 0, size);
i2d_SSL_SESSION(sess, &serialized); i2d_SSL_SESSION(sess, &session_data);
unsigned int session_id_length; unsigned int session_id_length;
const unsigned char* session_id = SSL_SESSION_get_id(sess, const unsigned char* session_id_data = SSL_SESSION_get_id(sess,
&session_id_length); &session_id_length);
Local<Object> session = Buffer::Copy( Local<Object> session_id = Buffer::Copy(
env, env,
reinterpret_cast<const char*>(session_id), reinterpret_cast<const char*>(session_id_data),
session_id_length).ToLocalChecked(); session_id_length).ToLocalChecked();
Local<Value> argv[] = { session, buff }; Local<Value> argv[] = { session_id, session };
w->new_session_wait_ = true; w->new_session_wait_ = true;
w->MakeCallback(env->onnewsession_string(), arraysize(argv), argv); w->MakeCallback(env->onnewsession_string(), arraysize(argv), argv);