Skip to content

Commit df268f9

Browse 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

2 files changed

Lines changed: 7 additions & 19 deletions

File tree

‎doc/api/tls.markdown‎

Lines changed: 3 additions & 3 deletions
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

‎lib/_tls_wrap.js‎

Lines 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
consttls_wrap=process.binding('tls_wrap');
1515
constTCP=process.binding('tcp_wrap').TCP;
1616
constPipe=process.binding('pipe_wrap').Pipe;
17-
constdefaultSessionIdContext=getDefaultSessionIdContext();
18-
19-
functiongetDefaultSessionIdContext(){
20-
vardefaultText=process.argv.join(' ');
21-
/* SSL_MAX_SID_CTX_LENGTH is 128 bits */
22-
if(process.config.variables.openssl_fips){
23-
returncrypto.createHash('sha1')
24-
.update(defaultText)
25-
.digest('hex').slice(0,32);
26-
}else{
27-
returncrypto.createHash('md5')
28-
.update(defaultText)
29-
.digest('hex');
30-
}
31-
}
3217

3318
functiononhandshakestart(){
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)