--use-system-ca
Node.js 使用系统存储中受信任的 CA 证书,并可以配合 --use-bundled-ca 选项和 NODE_EXTRA_CA_CERTS 环境变量使用。在 Windows 和 macOS 以外的平台上,它会从 OpenSSL 信任的目录和文件中加载证书,类似于 --use-openssl-ca,不同之处在于它在首次加载后会缓存证书。
【Node.js uses the trusted CA certificates present in the system store along with
the --use-bundled-ca option and the NODE_EXTRA_CA_CERTS environment variable.
On platforms other than Windows and macOS, this loads certificates from the directory
and file trusted by OpenSSL, similar to --use-openssl-ca, with the difference being
that it caches the certificates after first load.】
在 Windows 和 macOS 上,证书信任策略计划遵循 Chromium 本地信任证书的策略:
【On Windows and macOS, the certificate trust policy is planned to follow Chromium's policy for locally trusted certificates:】
在 macOS 上,遵循以下设置:
【On macOS, the following settings are respected:】
- 默认钥匙串和系统钥匙串
- 信任:
- 任何将“使用此证书时”标志设置为“始终信任”的证书,或
- 任何将“安全套接字层(SSL)”标志设置为“始终信任”的证书。
- 不信任:
- 任何“使用此证书时”标志设置为“永不信任”的证书,或
- 任何将“安全套接字层(SSL)”标志设置为“永不信任”的证书。
- 信任:
在 Windows 上,将遵循以下设置(与 Chromium 的策略不同,目前不支持不信任和中间 CA):
【On Windows, the following settings are respected (unlike Chromium's policy, distrust and intermediate CA are not currently supported):】
- 本地计算机(通过
certlm.msc访问)- 信任:
- 受信任的根证书颁发机构
- 可信赖的人
- 企业信任 -> 企业 -> 受信任的根证书颁发机构
- 企业信任 -> 企业 -> 可信人员
- 企业信任 -> 组策略 -> 受信任的根证书颁发机构
- 企业信任 -> 组策略 -> 受信任的人员
- 信任:
- 当前用户(通过
certmgr.msc访问)- 信任:
- 受信任的根证书颁发机构
- 企业信任 -> 组策略 -> 受信任的根证书颁发机构
- 信任:
在 Windows 和 macOS 上,Node.js 会在使用证书之前检查用户的证书设置,确保这些设置没有禁止其用于 TLS 服务器身份验证。
【On Windows and macOS, Node.js would check that the user settings for the certificates do not forbid them for TLS server authentication before using them.】
在其他系统上,Node.js 会从默认证书文件(通常是 /etc/ssl/cert.pem)和默认证书目录(通常是 /etc/ssl/certs)加载证书,这些位置是 Node.js 所链接的 OpenSSL 版本所遵循的。通常,这在主要的 Linux 发行版和其他类 Unix 系统上都能正常工作。如果设置了覆盖 OpenSSL 的环境变量(通常是 SSL_CERT_FILE 和 SSL_CERT_DIR,具体取决于 Node.js 所链接的 OpenSSL 的配置),则会使用指定的路径来加载证书。如果 Node.js 所链接的 OpenSSL 版本使用的常规路径与用户的系统配置不一致,这些环境变量可以作为一种解决方法。
【On other systems, Node.js loads certificates from the default certificate file
(typically /etc/ssl/cert.pem) and default certificate directory (typically
/etc/ssl/certs) that the version of OpenSSL that Node.js links to respects.
This typically works with the convention on major Linux distributions and other
Unix-like systems. If the overriding OpenSSL environment variables
(typically SSL_CERT_FILE and SSL_CERT_DIR, depending on the configuration
of the OpenSSL that Node.js links to) are set, the specified paths will be used to load
certificates instead. These environment variables can be used as workarounds
if the conventional paths used by the version of OpenSSL Node.js links to are
not consistent with the system configuration that the users have for some reason.】