Skip to content
Open
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
22 changes: 14 additions & 8 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ const noop = () => {};
let ipServernameWarned = false;
let tlsTracingWarned = false;

let defaultSessionIdContext = null;

function lazyDefaultSessionIdContext() {
if (defaultSessionIdContext === null) {
defaultSessionIdContext = crypto.createHash('sha1')
.update(process.argv.length === 1 ? process.argv[0] : process.argv.join(' '))
.digest('hex')
.slice(0, 32);
}
return defaultSessionIdContext;
}

// Server side times how long a handshake is taking to protect against slow
// handshakes being used for DoS.
function onhandshakestart(now) {
Expand Down Expand Up @@ -1472,10 +1484,7 @@ Server.prototype.setSecureContext = function(options) {
if (options.sessionIdContext) {
this.sessionIdContext = options.sessionIdContext;
} else {
this.sessionIdContext = crypto.createHash('sha1')
.update(process.argv.join(' '))
.digest('hex')
.slice(0, 32);
this.sessionIdContext = lazyDefaultSessionIdContext();
}

if (options.sessionTimeout)
Expand Down Expand Up @@ -1570,10 +1579,7 @@ Server.prototype.setOptions = deprecate(function(options) {
if (options.sessionIdContext) {
this.sessionIdContext = options.sessionIdContext;
} else {
this.sessionIdContext = crypto.createHash('sha1')
.update(process.argv.join(' '))
.digest('hex')
.slice(0, 32);
this.sessionIdContext = lazyDefaultSessionIdContext();
}
if (options.pskCallback) this[kPskCallback] = options.pskCallback;
if (options.pskIdentityHint) this[kPskIdentityHint] = options.pskIdentityHint;
Expand Down