FIPS 模式


【FIPS mode】

在使用 OpenSSL 3 时,Node.js 支持 FIPS 140-2,但需配合合适的 OpenSSL 3 提供程序使用,例如 来自 OpenSSL 3 的 FIPS 提供程序,可按照 OpenSSL 的 FIPS 自述文件 中的说明进行安装。

【When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate OpenSSL 3 provider, such as the FIPS provider from OpenSSL 3 which can be installed by following the instructions in OpenSSL's FIPS README file.】

对于 Node.js 中的 FIPS 支持,你需要:

【For FIPS support in Node.js you will need:】

  • 正确安装的 OpenSSL 3 FIPS 提供程序。
  • OpenSSL 3 FIPS 模块配置文件
  • 一个引用 FIPS 模块配置文件的 OpenSSL 3 配置文件。

Node.js 需要使用一个指向 FIPS 提供程序的 OpenSSL 配置文件进行配置。一个示例配置文件如下所示:

【Node.js will need to be configured with an OpenSSL configuration file that points to the FIPS provider. An example configuration file looks like this:】

nodejs_conf = nodejs_init

.include /<absolute path>/fipsmodule.cnf

[nodejs_init]
providers = provider_sect

[provider_sect]
default = default_sect
# The fips section name should match the section name inside the
# included fipsmodule.cnf.
fips = fips_sect

[default_sect]
activate = 1 

fipsmodule.cnf 是 FIPS 模块配置文件,由 FIPS 提供程序安装步骤生成:

【where fipsmodule.cnf is the FIPS module configuration file generated from the FIPS provider installation step:】

openssl fipsinstall 

OPENSSL_CONF 环境变量设置为指向你的配置文件,并将 OPENSSL_MODULES 设置为 FIPS 提供程序动态库的位置。例如。

【Set the OPENSSL_CONF environment variable to point to your configuration file and OPENSSL_MODULES to the location of the FIPS provider dynamic library. e.g.】

export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules 

然后可以通过以下方式在 Node.js 中启用 FIPS 模式:

【FIPS mode can then be enabled in Node.js either by:】

  • 使用 --enable-fips--force-fips 命令行标志启动 Node.js。
  • 以编程方式调用 crypto.setFips(true)

在 Node.js 中可以通过 OpenSSL 配置文件可选地启用 FIPS 模式。例如

【Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration file. e.g.】

nodejs_conf = nodejs_init

.include /<absolute path>/fipsmodule.cnf

[nodejs_init]
providers = provider_sect
alg_section = algorithm_sect

[provider_sect]
default = default_sect
# The fips section name should match the section name inside the
# included fipsmodule.cnf.
fips = fips_sect

[default_sect]
activate = 1

[algorithm_sect]
default_properties = fips=yes