mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
crypto: ability to select cert store at runtime
PR-URL: https://github.com/nodejs/node/pull/8334 Backport-PR-URL: https://github.com/nodejs/node/pull/11794 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
This commit is contained in:
1 parent
fd9bb56f9a
commit
e72749b319
5 files changed
+96
-9
No files matched your search
@@ -243,6 +243,24 @@ Load an OpenSSL configuration file on startup. Among other uses, this can be
|
||||
used to enable FIPS-compliant crypto if Node.js is built with
|
||||
`./configure --openssl-fips`.
|
||||
|
||||
### `--use-openssl-ca`, `--use-bundled-ca`
|
||||
<!-- YAML
|
||||
added: REPLACEME
|
||||
-->
|
||||
|
||||
Use OpenSSL's default CA store or use bundled Mozilla CA store as supplied by
|
||||
current NodeJS version. The default store is selectable at build-time.
|
||||
|
||||
Using OpenSSL store allows for external modifications of the store. For most
|
||||
Linux and BSD distributions, this store is maintained by the distribution
|
||||
maintainers and system administrators. OpenSSL CA store location is dependent on
|
||||
configuration of the OpenSSL library but this can be altered at runtime using
|
||||
environmental variables.
|
||||
|
||||
The bundled CA store, as supplied by NodeJS, is a snapshot of Mozilla CA store
|
||||
that is fixed at release time. It is identical on all supported platforms.
|
||||
|
||||
See `SSL_CERT_DIR` and `SSL_CERT_FILE`.
|
||||
|
||||
### `--icu-data-dir=file`
|
||||
<!-- YAML
|
||||
@@ -340,6 +358,24 @@ used to enable FIPS-compliant crypto if Node.js is built with `./configure
|
||||
If the [`--openssl-config`][] command line option is used, the environment
|
||||
variable is ignored.
|
||||
|
||||
### `SSL_CERT_DIR=dir`
|
||||
|
||||
If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's directory
|
||||
containing trusted certificates.
|
||||
|
||||
Note: Be aware that unless the child environment is explicitly set, this
|
||||
evironment variable will be inherited by any child processes, and if they use
|
||||
OpenSSL, it may cause them to trust the same CAs as node.
|
||||
|
||||
### `SSL_CERT_FILE=file`
|
||||
|
||||
If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's file
|
||||
containing trusted certificates.
|
||||
|
||||
Note: Be aware that unless the child environment is explicitly set, this
|
||||
evironment variable will be inherited by any child processes, and if they use
|
||||
OpenSSL, it may cause them to trust the same CAs as node.
|
||||
|
||||
[emit_warning]: process.html#process_process_emitwarning_warning_name_ctor
|
||||
[Buffer]: buffer.html#buffer_buffer
|
||||
[debugger]: debugger.html
|
||||
|
||||
+25
@@ -172,6 +172,22 @@ Load an OpenSSL configuration file on startup. Among other uses, this can be
|
||||
used to enable FIPS-compliant crypto if Node.js is built with
|
||||
\fB./configure \-\-openssl\-fips\fR.
|
||||
|
||||
.TP
|
||||
.BR \-\-use\-openssl\-ca,\-\-use\-bundled\-ca
|
||||
Use OpenSSL's default CA store or use bundled Mozilla CA store as supplied by
|
||||
current NodeJS version. The default store is selectable at build-time.
|
||||
|
||||
Using OpenSSL store allows for external modifications of the store. For most
|
||||
Linux and BSD distributions, this store is maintained by the distribution
|
||||
maintainers and system administrators. OpenSSL CA store location is dependent on
|
||||
configuration of the OpenSSL library but this can be altered at runtime using
|
||||
environmental variables.
|
||||
|
||||
The bundled CA store, as supplied by NodeJS, is a snapshot of Mozilla CA store
|
||||
that is fixed at release time. It is identical on all supported platforms.
|
||||
|
||||
See \fBSSL_CERT_DIR\fR and \fBSSL_CERT_FILE\fR.
|
||||
|
||||
.TP
|
||||
.BR \-\-icu\-data\-dir =\fIfile\fR
|
||||
Specify ICU data load path. (overrides \fBNODE_ICU_DATA\fR)
|
||||
@@ -216,6 +232,7 @@ Setting this will void any guarantee that stdio will not be interleaved or
|
||||
dropped at program exit. \fBAvoid use.\fR
|
||||
|
||||
.TP
|
||||
|
||||
.BR OPENSSL_CONF = \fIfile\fR
|
||||
Load an OpenSSL configuration file on startup. Among other uses, this can be
|
||||
used to enable FIPS-compliant crypto if Node.js is built with
|
||||
@@ -225,6 +242,14 @@ If the
|
||||
\fB\-\-openssl\-config\fR
|
||||
command line option is used, the environment variable is ignored.
|
||||
|
||||
.BR SSL_CERT_DIR = \fIdir\fR
|
||||
If \fB\-\-use\-openssl\-ca\fR is enabled, this overrides and sets OpenSSL's directory
|
||||
containing trusted certificates.
|
||||
|
||||
.TP
|
||||
.BR SSL_CERT_FILE = \fIfile\fR
|
||||
If \fB\-\-use\-openssl\-ca\fR is enabled, this overrides and sets OpenSSL's
|
||||
file containing trusted certificates.
|
||||
|
||||
.SH BUGS
|
||||
Bugs are tracked in GitHub Issues:
|
||||
|
||||
+24
-1
@@ -174,6 +174,14 @@ static std::string icu_data_dir; // NOLINT(runtime/string)
|
||||
bool no_deprecation = false;
|
||||
|
||||
#if HAVE_OPENSSL
|
||||
// use OpenSSL's cert store instead of bundled certs
|
||||
bool ssl_openssl_cert_store =
|
||||
#if defined(NODE_OPENSSL_CERT_STORE)
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
|
||||
# if NODE_FIPS_MODE
|
||||
// used by crypto module
|
||||
bool enable_fips_crypto = false;
|
||||
@@ -3685,7 +3693,18 @@ static void PrintHelp() {
|
||||
" --v8-options print v8 command line options\n"
|
||||
" --v8-pool-size=num set v8's thread pool size\n"
|
||||
#if HAVE_OPENSSL
|
||||
" --tls-cipher-list=val use an alternative default TLS cipher list\n"
|
||||
" --tls-cipher-list=val use an alternative default TLS cipher "
|
||||
"list\n"
|
||||
" --use-bundled-ca use bundled CA store"
|
||||
#if !defined(NODE_OPENSSL_CERT_STORE)
|
||||
" (default)"
|
||||
#endif
|
||||
"\n"
|
||||
" --use-openssl-ca use OpenSSL's default CA store"
|
||||
#if defined(NODE_OPENSSL_CERT_STORE)
|
||||
" (default)"
|
||||
#endif
|
||||
"\n"
|
||||
#if NODE_FIPS_MODE
|
||||
" --enable-fips enable FIPS crypto at startup\n"
|
||||
" --force-fips force FIPS crypto (cannot be disabled)\n"
|
||||
@@ -3854,6 +3873,10 @@ static void ParseArgs(int* argc,
|
||||
#if HAVE_OPENSSL
|
||||
} else if (strncmp(arg, "--tls-cipher-list=", 18) == 0) {
|
||||
default_cipher_list = arg + 18;
|
||||
} else if (strncmp(arg, "--use-openssl-ca", 16) == 0) {
|
||||
ssl_openssl_cert_store = true;
|
||||
} else if (strncmp(arg, "--use-bundled-ca", 16) == 0) {
|
||||
ssl_openssl_cert_store = false;
|
||||
#if NODE_FIPS_MODE
|
||||
} else if (strcmp(arg, "--enable-fips") == 0) {
|
||||
enable_fips_crypto = true;
|
||||
|
||||
+4
-1
@@ -179,9 +179,12 @@ typedef intptr_t ssize_t;
|
||||
namespace node {
|
||||
|
||||
NODE_EXTERN extern bool no_deprecation;
|
||||
#if HAVE_OPENSSL && NODE_FIPS_MODE
|
||||
#if HAVE_OPENSSL
|
||||
NODE_EXTERN extern bool ssl_openssl_cert_store;
|
||||
# if NODE_FIPS_MODE
|
||||
NODE_EXTERN extern bool enable_fips_crypto;
|
||||
NODE_EXTERN extern bool force_fips_crypto;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
NODE_EXTERN int Start(int argc, char *argv[]);
|
||||
|
||||
+7
-7
@@ -708,14 +708,14 @@ static X509_STORE* NewRootCertStore() {
|
||||
}
|
||||
|
||||
X509_STORE* store = X509_STORE_new();
|
||||
#if defined(NODE_OPENSSL_CERT_STORE)
|
||||
X509_STORE_set_default_paths(store);
|
||||
#else
|
||||
for (X509 *cert : root_certs_vector) {
|
||||
X509_up_ref(cert);
|
||||
X509_STORE_add_cert(store, cert);
|
||||
if (ssl_openssl_cert_store) {
|
||||
X509_STORE_set_default_paths(store);
|
||||
} else {
|
||||
for (X509 *cert : root_certs_vector) {
|
||||
X509_up_ref(cert);
|
||||
X509_STORE_add_cert(store, cert);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return store;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user