--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 similar to Chromium's policy for locally trusted certificates, but with some differences:

在 macOS 上,遵循以下设置:

🌐 On macOS, the following settings are respected:

  • 默认密钥串和系统密钥串
    • 信任:
      • 任何将“使用此证书时”标志设置为“始终信任”的证书,或
      • 任何将“安全套接字层 (SSL)”标志设置为“始终信任”的证书。
    • 证书也必须有效,其“X.509 基本策略”设置为“始终信任”。

在 Windows 系统上,会遵循以下设置:

🌐 On Windows, the following settings are respected:

  • 本地计算机(通过 certlm.msc 访问)
    • 信任:
      • 受信任的根证书颁发机构
      • 可信赖的人
      • 企业信任 -> 企业 -> 受信任的根证书颁发机构
      • 企业信任 -> 企业 -> 可信人员
      • 企业信任 -> 组策略 -> 受信任的根证书颁发机构
      • 企业信任 -> 组策略 -> 受信任的人员
  • 当前用户(通过 certmgr.msc 访问)
    • 信任:
      • 受信任的根证书颁发机构
      • 企业信任 -> 组策略 -> 受信任的根证书颁发机构

在 Windows 和 macOS 上,Node.js 会在使用受信任证书进行 TLS 服务器身份验证之前,检查用户设置是否禁止使用这些证书。

🌐 On Windows and macOS, Node.js would check that the user settings for the trusted certificates do not forbid them for TLS server authentication before using them.

Node.js 目前不支持根据系统设置不信任或撤销来自其他来源的证书。

🌐 Node.js currently does not support distrust/revocation of certificates from another source based on system settings.

在其他系统上,Node.js 会从默认证书文件(通常是 /etc/ssl/cert.pem)和默认证书目录(通常是 /etc/ssl/certs)加载证书,这些位置是 Node.js 所链接的 OpenSSL 版本所遵循的。通常,这在主要的 Linux 发行版和其他类 Unix 系统上都能正常工作。如果设置了覆盖 OpenSSL 的环境变量(通常是 SSL_CERT_FILESSL_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.