tls.getCACertificates([type])


  • type <string> | <undefined> 将返回的 CA 证书类型。有效值为 "default""system""bundled""extra"。默认值:"default"

    ¥type <string> | <undefined> The type of CA certificates that will be returned. Valid values are "default", "system", "bundled" and "extra". Default: "default".

  • 返回:<string[]> PEM 编码证书数组。如果同一证书重复存储在多个来源中,则数组可能包含重复项。

    ¥Returns: <string[]> An array of PEM-encoded certificates. The array may contain duplicates if the same certificate is repeatedly stored in multiple sources.

返回一个包含来自各种来源的 CA 证书的数组,具体取决于 type

¥Returns an array containing the CA certificates from various sources, depending on type:

  • "default":返回 Node.js TLS 客户端默认使用的 CA 证书。

    ¥"default": return the CA certificates that will be used by the Node.js TLS clients by default.

    • 当启用 --use-bundled-ca(默认)或未启用 --use-openssl-ca 时,这将包括来自打包的 Mozilla CA 存储的 CA 证书。

      ¥When --use-bundled-ca is enabled (default), or --use-openssl-ca is not enabled, this would include CA certificates from the bundled Mozilla CA store.

    • 当启用 --use-system-ca 时,这还将包括来自系统受信任存储的证书。

      ¥When --use-system-ca is enabled, this would also include certificates from the system's trusted store.

    • 当使用 NODE_EXTRA_CA_CERTS 时,这还将包括从指定文件加载的证书。

      ¥When NODE_EXTRA_CA_CERTS is used, this would also include certificates loaded from the specified file.

  • "system":根据 --use-system-ca 设置的规则,返回从系统的受信任存储中加载的 CA 证书。当未启用 --use-system-ca 时,这可用于从系统获取证书。

    ¥"system": return the CA certificates that are loaded from the system's trusted store, according to rules set by --use-system-ca. This can be used to get the certificates from the system when --use-system-ca is not enabled.

  • "bundled":从打包的 Mozilla CA 存储中返回 CA 证书。这与 tls.rootCertificates 相同。

    ¥"bundled": return the CA certificates from the bundled Mozilla CA store. This would be the same as tls.rootCertificates.

  • "extra":返回从 NODE_EXTRA_CA_CERTS 加载的 CA 证书。如果未设置 NODE_EXTRA_CA_CERTS,则它是一个空数组。

    ¥"extra": return the CA certificates loaded from NODE_EXTRA_CA_CERTS. It's an empty array if NODE_EXTRA_CA_CERTS is not set.