Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls, binding: backport of process.binding('config') and regression fix #7551

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ An example of the possible output looks like:
}
```

*Note: the `process.config` property is **not** read-only and there are existing
modules in the ecosystem that are known to extend, modify, or entirely replace
the value of `process.config`.*

## process.connected

* {Boolean} Set to false after `process.disconnect()` is called
Expand Down
2 changes: 1 addition & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const defaultSessionIdContext = getDefaultSessionIdContext();
function getDefaultSessionIdContext() {
var defaultText = process.argv.join(' ');
/* SSL_MAX_SID_CTX_LENGTH is 128 bits */
if (process.config.variables.openssl_fips) {
if (process.binding('config').fipsMode) {
return crypto.createHash('sha1')
.update(defaultText)
.digest('hex').slice(0, 32);
Expand Down
1 change: 1 addition & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
'src/js_stream.cc',
'src/node.cc',
'src/node_buffer.cc',
'src/node_config.cc',
'src/node_constants.cc',
'src/node_contextify.cc',
'src/node_file.cc',
Expand Down
39 changes: 39 additions & 0 deletions src/node_config.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "node.h"
#include "env.h"
#include "env-inl.h"
#include "util.h"
#include "util-inl.h"


namespace node {

using v8::Context;
using v8::Local;
using v8::Object;
using v8::Value;
using v8::ReadOnly;

// The config binding is used to provide an internal view of compile or runtime
// config options that are required internally by lib/*.js code. This is an
// alternative to dropping additional properties onto the process object as
// has been the practice previously in node.cc.

#define READONLY_BOOLEAN_PROPERTY(str) \
do { \
target->DefineOwnProperty(env->context(), \
OneByteString(env->isolate(), str), \
True(env->isolate()), ReadOnly).FromJust(); \
} while (0)

void InitConfig(Local<Object> target,
Local<Value> unused,
Local<Context> context) {
#ifdef NODE_FIPS_MODE
Environment* env = Environment::GetCurrent(context);
READONLY_BOOLEAN_PROPERTY("fipsMode");
#endif
}

} // namespace node

NODE_MODULE_CONTEXT_AWARE_BUILTIN(config, node::InitConfig)