Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit df268f9

Browse filesBrowse files
stefanmbindutny
authored andcommitted
tls: use SHA1 for sessionIdContext
FIPS 140-2 disallows use of MD5, which is used to derive the default sessionIdContext for tls.createServer(). PR-URL: #3866 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 424ae5d commit df268f9
Copy full SHA for df268f9

File tree

Expand file treeCollapse file tree

2 files changed

+7
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-19
lines changed
Open diff view settings
Collapse file

‎doc/api/tls.markdown‎

Copy file name to clipboardExpand all lines: doc/api/tls.markdown
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,9 @@ automatically set as a listener for the [secureConnection][] event. The
841841
NOTE: Automatically shared between `cluster` module workers.
842842

843843
- `sessionIdContext`: A string containing an opaque identifier for session
844-
resumption. If `requestCert` is `true`, the default is MD5 hash value
845-
generated from command-line. (In FIPS mode a truncated SHA1 hash is
846-
used instead.) Otherwise, the default is not provided.
844+
resumption. If `requestCert` is `true`, the default is a 128 bit
845+
truncated SHA1 hash value generated from command-line. Otherwise,
846+
the default is not provided.
847847

848848
- `secureProtocol`: The SSL method to use, e.g. `SSLv3_method` to force
849849
SSL version 3. The possible values depend on your installation of
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+4-16Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ const Timer = process.binding('timer_wrap').Timer;
1414
const tls_wrap = process.binding('tls_wrap');
1515
const TCP = process.binding('tcp_wrap').TCP;
1616
const Pipe = process.binding('pipe_wrap').Pipe;
17-
const defaultSessionIdContext = getDefaultSessionIdContext();
18-
19-
function getDefaultSessionIdContext() {
20-
var defaultText = process.argv.join(' ');
21-
/* SSL_MAX_SID_CTX_LENGTH is 128 bits */
22-
if (process.config.variables.openssl_fips) {
23-
return crypto.createHash('sha1')
24-
.update(defaultText)
25-
.digest('hex').slice(0, 32);
26-
} else {
27-
return crypto.createHash('md5')
28-
.update(defaultText)
29-
.digest('hex');
30-
}
31-
}
3217

3318
function onhandshakestart() {
3419
debug('onhandshakestart');
@@ -908,7 +893,10 @@ Server.prototype.setOptions = function(options) {
908893
if (options.sessionIdContext) {
909894
this.sessionIdContext = options.sessionIdContext;
910895
} else {
911-
this.sessionIdContext = defaultSessionIdContext;
896+
this.sessionIdContext = crypto.createHash('sha1')
897+
.update(process.argv.join(' '))
898+
.digest('hex')
899+
.slice(0, 32);
912900
}
913901
};
914902

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.