GeezerVison is showing github.com — src: add --use-bundled-ca --use-openssl-ca check · nodejs/node@758dc81
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/node.cc +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3887,6 +3887,8 @@ static void ParseArgs(int* argc, | 3887 | 3887 | const char** new_exec_argv = new const char*[nargs]; | 3888 | 3888 | const char** new_v8_argv = new const char*[nargs]; | 3889 | 3889 | const char** new_argv = new const char*[nargs]; | | 3890 | + bool use_bundled_ca = false; | | 3891 | + bool use_openssl_ca = false; | 3890 | 3892 |
| 3891 | 3893 | for (unsigned int i = 0; i < nargs; ++i) { | 3892 | 3894 | new_exec_argv[i] = nullptr; | @@ -3992,7 +3994,9 @@ static void ParseArgs(int* argc, | 3992 | 3994 | default_cipher_list = arg + 18; | 3993 | 3995 | } else if (strncmp(arg, "--use-openssl-ca", 16) == 0) { | 3994 | 3996 | ssl_openssl_cert_store = true; | | 3997 | + use_openssl_ca = true; | 3995 | 3998 | } else if (strncmp(arg, "--use-bundled-ca", 16) == 0) { | | 3999 | + use_bundled_ca = true; | 3996 | 4000 | ssl_openssl_cert_store = false; | 3997 | 4001 | #if NODE_FIPS_MODE | 3998 | 4002 | } else if (strcmp(arg, "--enable-fips") == 0) { | @@ -4027,6 +4031,16 @@ static void ParseArgs(int* argc, | 4027 | 4031 | index += args_consumed; | 4028 | 4032 | } | 4029 | 4033 |
| | 4034 | +#if HAVE_OPENSSL | | 4035 | + if (use_openssl_ca && use_bundled_ca) { | | 4036 | + fprintf(stderr, | | 4037 | + "%s: either --use-openssl-ca or --use-bundled-ca can be used, " | | 4038 | + "not both\n", | | 4039 | + argv[0]); | | 4040 | + exit(9); | | 4041 | + } | | 4042 | +#endif | | 4043 | + | 4030 | 4044 | // Copy remaining arguments. | 4031 | 4045 | const unsigned int args_left = nargs - index; | 4032 | 4046 |
| |
Collapse file Copy file name to clipboard +30Lines changed: 30 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 | + | | 8 | +const assert = require('assert'); | | 9 | +const os = require('os'); | | 10 | +const childProcess = require('child_process'); | | 11 | +const result = childProcess.spawnSync( | | 12 | + process.execPath, | | 13 | + [ '--use-bundled-ca', '--use-openssl-ca', '-p', 'process.version' ], | | 14 | + { encoding: 'utf8' } | | 15 | +); | | 16 | + | | 17 | +assert.strictEqual(result.stderr, `${process.execPath | | 18 | +}: either --use-openssl-ca or --use-bundled-ca can be used, not both${os.EOL}` | | 19 | +); | | 20 | +assert.strictEqual(result.status, 9); | | 21 | + | | 22 | +const useBundledCA = childProcess.spawnSync(process.execPath, [ | | 23 | + '--use-bundled-ca', | | 24 | + '-p', 'process.version']); | | 25 | +assert.strictEqual(useBundledCA.status, 0); | | 26 | + | | 27 | +const useOpenSSLCA = childProcess.spawnSync(process.execPath, [ | | 28 | + '--use-openssl-ca', | | 29 | + '-p', 'process.version']); | | 30 | +assert.strictEqual(useOpenSSLCA.status, 0); |
|