Skip to content

Commit 06327e5

Browse files
jasnellMyles Borins
authored and
Myles Borins
committed
tls: use process.binding('config') to detect fips mode
When the fips mode check was added sometime in v4 it caused a regression in some edge cases (see #6114) because `process.config` can be overwritten by userland modules. This switches to using the backported process.binding('config') to fix the regression. Fixes: #6114 PR-URL: #7551 Reviewed-By: Myles Borins <[email protected]>
1 parent b9136c0 commit 06327e5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/_tls_wrap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const defaultSessionIdContext = getDefaultSessionIdContext();
1919
function getDefaultSessionIdContext() {
2020
var defaultText = process.argv.join(' ');
2121
/* SSL_MAX_SID_CTX_LENGTH is 128 bits */
22-
if (process.config.variables.openssl_fips) {
22+
if (process.binding('config').fipsMode) {
2323
return crypto.createHash('sha1')
2424
.update(defaultText)
2525
.digest('hex').slice(0, 32);

src/node_config.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ using v8::ReadOnly;
2828
void InitConfig(Local<Object> target,
2929
Local<Value> unused,
3030
Local<Context> context) {
31-
// Environment* env = Environment::GetCurrent(context);
31+
#ifdef NODE_FIPS_MODE
32+
Environment* env = Environment::GetCurrent(context);
33+
READONLY_BOOLEAN_PROPERTY("fipsMode");
34+
#endif
3235
}
3336

3437
} // namespace node

0 commit comments

Comments
 (0)