Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
src: remove unnecessary comment and add a CHECK in crypto_tls.cc
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
  • Loading branch information
RaisinTen committed Sep 10, 2021
commit 9a39eb517da12898919ca362e3eb28117f03b2b2
9 changes: 1 addition & 8 deletions src/crypto/crypto_tls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,19 @@ int NewSessionCallback(SSL* s, SSL_SESSION* sess) {
return 0;

// Serialize session
// TODO(@jasnell): An AllocatedBuffer or BackingStore would be better
Comment thread
RaisinTen marked this conversation as resolved.
// here to start eliminating unnecessary uses of Buffer where an ordinary
// Uint8Array would do just fine.
Local<Object> session = Buffer::New(env, size).FromMaybe(Local<Object>());
if (UNLIKELY(session.IsEmpty()))
return 0;

unsigned char* session_data =
reinterpret_cast<unsigned char*>(Buffer::Data(session));

memset(session_data, 0, size);
Comment thread
RaisinTen marked this conversation as resolved.
i2d_SSL_SESSION(sess, &session_data);
CHECK_EQ(i2d_SSL_SESSION(sess, &session_data), size);

unsigned int session_id_length;
const unsigned char* session_id_data =
SSL_SESSION_get_id(sess, &session_id_length);

// TODO(@jasnell): An AllocatedBuffer or BackingStore would be better
// here to start eliminating unnecessary uses of Buffer where an ordinary
// Uint8Array would do just fine
Local<Object> session_id = Buffer::Copy(
env,
reinterpret_cast<const char*>(session_id_data),
Expand Down