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 8a7db9d

Browse filesBrowse files
committed
src: add --use-bundled-ca --use-openssl-ca check
The --use-bundled-ca and --use-openssl-ca command line arguments are mutually exclusive but can both be used on the same command line. This commit adds a check if both options are used. Fixes: #12083 PR-URL: #12087 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
1 parent 4d255b0 commit 8a7db9d
Copy full SHA for 8a7db9d

File tree

Expand file treeCollapse file tree

2 files changed

+45
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+45
-0
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3637,6 +3637,8 @@ static void ParseArgs(int* argc,
36373637
const char** new_v8_argv = new const char*[nargs];
36383638
const char** new_argv = new const char*[nargs];
36393639
const char** local_preload_modules = new const char*[nargs];
3640+
bool use_bundled_ca = false;
3641+
bool use_openssl_ca = false;
36403642

36413643
for (unsigned int i = 0; i < nargs; ++i) {
36423644
new_exec_argv[i] = nullptr;
@@ -3751,7 +3753,9 @@ static void ParseArgs(int* argc,
37513753
default_cipher_list = arg + 18;
37523754
} else if (strncmp(arg, "--use-openssl-ca", 16) == 0) {
37533755
ssl_openssl_cert_store = true;
3756+
use_openssl_ca = true;
37543757
} else if (strncmp(arg, "--use-bundled-ca", 16) == 0) {
3758+
use_bundled_ca = true;
37553759
ssl_openssl_cert_store = false;
37563760
#if NODE_FIPS_MODE
37573761
} else if (strcmp(arg, "--enable-fips") == 0) {
@@ -3786,6 +3790,16 @@ static void ParseArgs(int* argc,
37863790
index += args_consumed;
37873791
}
37883792

3793+
#if HAVE_OPENSSL
3794+
if (use_openssl_ca && use_bundled_ca) {
3795+
fprintf(stderr,
3796+
"%s: either --use-openssl-ca or --use-bundled-ca can be used, "
3797+
"not both\n",
3798+
argv[0]);
3799+
exit(9);
3800+
}
3801+
#endif
3802+
37893803
// Copy remaining arguments.
37903804
const unsigned int args_left = nargs - index;
37913805
memcpy(new_argv + new_argc, argv + index, args_left * sizeof(*argv));
Collapse file
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
// This test checks the usage of --use-bundled-ca and --use-openssl-ca arguments
3+
// to verify that both are not used at the same time.
4+
const common = require('../common');
5+
if (!common.hasCrypto) {
6+
common.skip('missing crypto');
7+
return;
8+
}
9+
const assert = require('assert');
10+
const os = require('os');
11+
const childProcess = require('child_process');
12+
const result = childProcess.spawnSync(process.execPath, [
13+
'--use-bundled-ca',
14+
'--use-openssl-ca',
15+
'-p', 'process.version'],
16+
{encoding: 'utf8'});
17+
18+
assert.strictEqual(result.stderr,
19+
process.execPath + ': either --use-openssl-ca or ' +
20+
'--use-bundled-ca can be used, not both' + os.EOL);
21+
assert.strictEqual(result.status, 9);
22+
23+
const useBundledCA = childProcess.spawnSync(process.execPath, [
24+
'--use-bundled-ca',
25+
'-p', 'process.version']);
26+
assert.strictEqual(useBundledCA.status, 0);
27+
28+
const useOpenSSLCA = childProcess.spawnSync(process.execPath, [
29+
'--use-openssl-ca',
30+
'-p', 'process.version']);
31+
assert.strictEqual(useOpenSSLCA.status, 0);

0 commit comments

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