| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dc77c6e commit a3bf4a2
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -363,6 +363,18 @@ misformatted, but any errors are otherwise ignored. | |||
| 363 | 363 | Note that neither the well known nor extra certificates are used when the `ca` | |
| 364 | 364 | options property is explicitly specified for a TLS or HTTPS client or server. | |
| 365 | 365 | ||
| 366 | + ### `OPENSSL_CONF=file` | ||
| 367 | + <!-- YAML | ||
| 368 | + added: REPLACEME | ||
| 369 | + --> | ||
| 370 | + | ||
| 371 | + Load an OpenSSL configuration file on startup. Among other uses, this can be | ||
| 372 | + used to enable FIPS-compliant crypto if Node.js is built with `./configure | ||
| 373 | + \-\-openssl\-fips`. | ||
| 374 | + | ||
| 375 | + If the [`--openssl-config`][] command line option is used, the environment | ||
| 376 | + variable is ignored. | ||
| 377 | + | ||
| 366 | 378 | ### `SSL_CERT_DIR=dir` | |
| 367 | 379 | ||
| 368 | 380 | If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's directory | |
@@ -386,3 +398,4 @@ OpenSSL, it may cause them to trust the same CAs as node. | |||
| 386 | 398 | [debugger]: debugger.html | |
| 387 | 399 | [REPL]: repl.html | |
| 388 | 400 | [SlowBuffer]: buffer.html#buffer_class_slowbuffer | |
| 401 | + [`--openssl-config`]: #cli_openssl_config_file | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -243,6 +243,16 @@ asynchronous when outputting to a TTY on platforms which support async stdio. | |||
| 243 | 243 | Setting this will void any guarantee that stdio will not be interleaved or | |
| 244 | 244 | dropped at program exit. \fBAvoid use.\fR | |
| 245 | 245 | ||
| 246 | + .TP | ||
| 247 | + .BR OPENSSL_CONF = \fIfile\fR | ||
| 248 | + Load an OpenSSL configuration file on startup. Among other uses, this can be | ||
| 249 | + used to enable FIPS-compliant crypto if Node.js is built with | ||
| 250 | + \fB./configure \-\-openssl\-fips\fR. | ||
| 251 | + | ||
| 252 | + If the | ||
| 253 | + \fB\-\-openssl\-config\fR | ||
| 254 | + command line option is used, the environment variable is ignored. | ||
| 255 | + | ||
| 246 | 256 | .TP | |
| 247 | 257 | .BR SSL_CERT_DIR = \fIdir\fR | |
| 248 | 258 | If \fB\-\-use\-openssl\-ca\fR is enabled, this overrides and sets OpenSSL's directory | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -174,7 +174,7 @@ bool ssl_openssl_cert_store = | |||
| 174 | 174 | bool enable_fips_crypto = false; | |
| 175 | 175 | bool force_fips_crypto = false; | |
| 176 | 176 | # endif // NODE_FIPS_MODE | |
| 177 | - const char* openssl_config = nullptr; | ||
| 177 | + std::string openssl_config; // NOLINT(runtime/string) | ||
| 178 | 178 | #endif // HAVE_OPENSSL | |
| 179 | 179 | ||
| 180 | 180 | // true if process warnings should be suppressed | |
@@ -3519,8 +3519,9 @@ static void PrintHelp() { | |||
| 3519 | 3519 | " --enable-fips enable FIPS crypto at startup\n" | |
| 3520 | 3520 | " --force-fips force FIPS crypto (cannot be disabled)\n" | |
| 3521 | 3521 | #endif /* NODE_FIPS_MODE */ | |
| 3522 | - " --openssl-config=path load OpenSSL configuration file from\n" | ||
| 3523 | - " the specified path\n" | ||
| 3522 | + " --openssl-config=file load OpenSSL configuration from the\n" | ||
| 3523 | + " specified file (overrides\n" | ||
| 3524 | + " OPENSSL_CONF)\n" | ||
| 3524 | 3525 | #endif /* HAVE_OPENSSL */ | |
| 3525 | 3526 | #if defined(NODE_HAVE_I18N_SUPPORT) | |
| 3526 | 3527 | " --icu-data-dir=dir set ICU data load path to dir\n" | |
@@ -3553,6 +3554,8 @@ static void PrintHelp() { | |||
| 3553 | 3554 | " prefixed to the module search path\n" | |
| 3554 | 3555 | "NODE_REPL_HISTORY path to the persistent REPL history\n" | |
| 3555 | 3556 | " file\n" | |
| 3557 | + "OPENSSL_CONF load OpenSSL configuration from file\n" | ||
| 3558 | + "\n" | ||
| 3556 | 3559 | "Documentation can be found at https://nodejs.org/\n"); | |
| 3557 | 3560 | } | |
| 3558 | 3561 | ||
@@ -3690,7 +3693,7 @@ static void ParseArgs(int* argc, | |||
| 3690 | 3693 | force_fips_crypto = true; | |
| 3691 | 3694 | #endif /* NODE_FIPS_MODE */ | |
| 3692 | 3695 | } else if (strncmp(arg, "--openssl-config=", 17) == 0) { | |
| 3693 | - openssl_config = arg + 17; | ||
| 3696 | + openssl_config.assign(arg + 17); | ||
| 3694 | 3697 | #endif /* HAVE_OPENSSL */ | |
| 3695 | 3698 | #if defined(NODE_HAVE_I18N_SUPPORT) | |
| 3696 | 3699 | } else if (strncmp(arg, "--icu-data-dir=", 15) == 0) { | |
@@ -4187,6 +4190,9 @@ void Init(int* argc, | |||
| 4187 | 4190 | SafeGetenv("NODE_PRESERVE_SYMLINKS", &text) && text[0] == '1'; | |
| 4188 | 4191 | } | |
| 4189 | 4192 | ||
| 4193 | + if (openssl_config.empty()) | ||
| 4194 | + SafeGetenv("OPENSSL_CONF", &openssl_config); | ||
| 4195 | + | ||
| 4190 | 4196 | // Parse a few arguments which are specific to Node. | |
| 4191 | 4197 | int v8_argc; | |
| 4192 | 4198 | const char** v8_argv; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5881,14 +5881,14 @@ void InitCryptoOnce() { | |||
| 5881 | 5881 | OPENSSL_no_config(); | |
| 5882 | 5882 | ||
| 5883 | 5883 | // --openssl-config=... | |
| 5884 | - if (openssl_config != nullptr) { | ||
| 5884 | + if (!openssl_config.empty()) { | ||
| 5885 | 5885 | OPENSSL_load_builtin_modules(); | |
| 5886 | 5886 | #ifndef OPENSSL_NO_ENGINE | |
| 5887 | 5887 | ENGINE_load_builtin_engines(); | |
| 5888 | 5888 | #endif | |
| 5889 | 5889 | ERR_clear_error(); | |
| 5890 | 5890 | CONF_modules_load_file( | |
| 5891 | - openssl_config, | ||
| 5891 | + openssl_config.c_str(), | ||
| 5892 | 5892 | nullptr, | |
| 5893 | 5893 | CONF_MFLAGS_DEFAULT_SECTION); | |
| 5894 | 5894 | int err = ERR_get_error(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ namespace node { | |||
| 36 | 36 | ||
| 37 | 37 | // Set in node.cc by ParseArgs with the value of --openssl-config. | |
| 38 | 38 | // Used in node_crypto.cc when initializing OpenSSL. | |
| 39 | - extern const char* openssl_config; | ||
| 39 | + extern std::string openssl_config; | ||
| 40 | 40 | ||
| 41 | 41 | // Set in node.cc by ParseArgs when --preserve-symlinks is used. | |
| 42 | 42 | // Used in node_config.cc to set a constant on process.binding('config') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,8 +37,9 @@ function testHelper(stream, args, expectedOutput, cmd, env) { | |||
| 37 | 37 | env: env | |
| 38 | 38 | }); | |
| 39 | 39 | ||
| 40 | - console.error('Spawned child [pid:' + child.pid + '] with cmd ' + | ||
| 41 | - cmd + ' and args \'' + args + '\''); | ||
| 40 | + console.error('Spawned child [pid:' + child.pid + '] with cmd \'' + | ||
| 41 | + cmd + '\' expect %j with args \'' + args + '\'' + | ||
| 42 | + ' OPENSSL_CONF=%j', expectedOutput, env.OPENSSL_CONF); | ||
| 42 | 43 | ||
| 43 | 44 | function childOk(child) { | |
| 44 | 45 | console.error('Child #' + ++num_children_ok + | |
@@ -92,10 +93,26 @@ testHelper( | |||
| 92 | 93 | compiledWithFips() ? FIPS_ENABLED : FIPS_DISABLED, | |
| 93 | 94 | 'require("crypto").fips', | |
| 94 | 95 | process.env); | |
| 95 | - // OPENSSL_CONF should _not_ be able to turn on FIPS mode | ||
| 96 | + | ||
| 97 | + // OPENSSL_CONF should be able to turn on FIPS mode | ||
| 96 | 98 | testHelper( | |
| 97 | 99 | 'stdout', | |
| 98 | 100 | [], | |
| 101 | + compiledWithFips() ? FIPS_ENABLED : FIPS_DISABLED, | ||
| 102 | + 'require("crypto").fips', | ||
| 103 | + addToEnv('OPENSSL_CONF', CNF_FIPS_ON)); | ||
| 104 | + | ||
| 105 | + // --openssl-config option should override OPENSSL_CONF | ||
| 106 | + testHelper( | ||
| 107 | + 'stdout', | ||
| 108 | + [`--openssl-config=${CNF_FIPS_ON}`], | ||
| 109 | + compiledWithFips() ? FIPS_ENABLED : FIPS_DISABLED, | ||
| 110 | + 'require("crypto").fips', | ||
| 111 | + addToEnv('OPENSSL_CONF', CNF_FIPS_OFF)); | ||
| 112 | + | ||
| 113 | + testHelper( | ||
| 114 | + 'stdout', | ||
| 115 | + [`--openssl-config=${CNF_FIPS_OFF}`], | ||
| 99 | 116 | FIPS_DISABLED, | |
| 100 | 117 | 'require("crypto").fips', | |
| 101 | 118 | addToEnv('OPENSSL_CONF', CNF_FIPS_ON)); | |
@@ -107,6 +124,7 @@ testHelper( | |||
| 107 | 124 | compiledWithFips() ? FIPS_ENABLED : OPTION_ERROR_STRING, | |
| 108 | 125 | 'require("crypto").fips', | |
| 109 | 126 | process.env); | |
| 127 | + | ||
| 110 | 128 | // OPENSSL_CONF should _not_ make a difference to --enable-fips | |
| 111 | 129 | testHelper( | |
| 112 | 130 | compiledWithFips() ? 'stdout' : 'stderr', | |
@@ -122,6 +140,7 @@ testHelper( | |||
| 122 | 140 | compiledWithFips() ? FIPS_ENABLED : OPTION_ERROR_STRING, | |
| 123 | 141 | 'require("crypto").fips', | |
| 124 | 142 | process.env); | |
| 143 | + | ||
| 125 | 144 | // Using OPENSSL_CONF should not make a difference to --force-fips | |
| 126 | 145 | testHelper( | |
| 127 | 146 | compiledWithFips() ? 'stdout' : 'stderr', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments