Skip to content

Commit

Permalink
crypto: use SSL_SESSION_get_id
Browse files Browse the repository at this point in the history
This accessor exists in OpenSSL 1.0.2, so it may be used already. This
is cherry-picked from PR #8491.

PR-URL: #15348
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
davidben authored and MylesBorins committed Oct 25, 2017
1 parent 78dc928 commit 6b08128
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1410,10 +1410,13 @@ int SSLWrap<Base>::NewSessionCallback(SSL* s, SSL_SESSION* sess) {
memset(serialized, 0, size);
i2d_SSL_SESSION(sess, &serialized);

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

0 comments on commit 6b08128

Please sign in to comment.