Commit 9a256b0

Browse files
panvaaduh95
authored andcommitted
doc: clarify OpenSSL FIPS configuration
Distinguish OpenSSL 3 provider setup from FIPS/property-query state, document configuration precedence and provider limitations, and retain the OpenSSL 1.1 and runtime control guidance. Regenerate the CLI manpage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64982 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 28f662b commit 9a256b0

4 files changed

Lines changed: 164 additions & 87 deletions

File tree

β€ŽBUILDING.mdβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
10321032
### Configure OpenSSL appname
10331033

10341034
Node.js can use an OpenSSL configuration file by specifying the environment
1035-
variable `OPENSSL_CONF`, or using the command line option `--openssl-conf`, and
1036-
if none of those are specified will default to reading the default OpenSSL
1037-
configuration file `openssl.cnf`. Node.js will only read a section that is by
1038-
default named `nodejs_conf`, but this name can be overridden using the following
1039-
configure option:
1035+
variable `OPENSSL_CONF`, or using the command line option `--openssl-config`,
1036+
which takes precedence. If neither is specified, Node.js defaults to reading the
1037+
default OpenSSL configuration file `openssl.cnf`. Node.js will only read a
1038+
section that is by default named `nodejs_conf`, but this name can be overridden
1039+
using the following configure option:
10401040

10411041
```bash
10421042
./configure --openssl-conf-name=<some_conf_name>
@@ -1048,6 +1048,8 @@ Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
10481048
[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
10491049
It is not necessary to rebuild Node.js to enable support for FIPS.
10501050

1051+
When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
1052+
10511053
See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
10521054
enable FIPS support in Node.js.
10531055

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,9 @@ priority than `--dns-result-order`.
881881
added: v6.0.0
882882
-->
883883

884-
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
885-
against FIPS-compatible OpenSSL.)
884+
Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
885+
`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
886+
Node.js must be built against a FIPS-capable OpenSSL.
886887

887888
### `--enable-source-maps`
888889

@@ -1561,8 +1562,8 @@ Disable loading native addons that are not [context-aware][].
15611562
added: v6.0.0
15621563
-->
15631564

1564-
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
1565-
(Same requirements as `--enable-fips`.)
1565+
Enable [FIPS mode][] at startup and prevent it from being disabled from script
1566+
code. The same OpenSSL requirements as [`--enable-fips`][] apply.
15661567

15671568
### `--force-node-api-uncaught-exceptions-policy`
15681569

@@ -2257,9 +2258,11 @@ usually only useful for developers debugging Node.js itself.
22572258
added: v6.9.0
22582259
-->
22592260

2260-
Load an OpenSSL configuration file on startup. Among other uses, this can be
2261-
used to enable FIPS-compliant crypto if Node.js is built
2262-
against FIPS-enabled OpenSSL.
2261+
Load an OpenSSL configuration file on startup. The file can activate an
2262+
OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
2263+
[FIPS mode][].
2264+
2265+
This option takes precedence over the `OPENSSL_CONF` environment variable.
22632266

22642267
### `--openssl-legacy-provider`
22652268

@@ -4234,9 +4237,8 @@ environment variable is arbitrary.
42344237
added: v6.11.0
42354238
-->
42364239

4237-
Load an OpenSSL configuration file on startup. Among other uses, this can be
4238-
used to enable FIPS-compliant crypto if Node.js is built with
4239-
`./configure --openssl-fips`.
4240+
Load an OpenSSL configuration file on startup. The file can be used as part of
4241+
a [FIPS mode][] configuration.
42404242

42414243
If the [`--openssl-config`][] command-line option is used, the environment
42424244
variable is ignored.
@@ -4443,6 +4445,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44434445
[ECMAScript module]: esm.md#modules-ecmascript-modules
44444446
[EventSource Web API]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
44454447
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
4448+
[FIPS mode]: crypto.md#fips-mode
44464449
[File System Permissions]: permissions.md#file-system-permissions
44474450
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
44484451
[Module resolution and loading]: packages.md#module-resolution-and-loading
@@ -4472,6 +4475,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44724475
[`--cpu-prof-dir`]: #--cpu-prof-dir
44734476
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
44744477
[`--disable-sigusr1`]: #--disable-sigusr1
4478+
[`--enable-fips`]: #--enable-fips
44754479
[`--env-file-if-exists`]: #--env-file-if-existsfile
44764480
[`--env-file`]: #--env-filefile
44774481
[`--experimental-sea-config`]: single-executable-applications.md#1-generating-single-executable-preparation-blobs

β€Ždoc/api/crypto.mdβ€Ž

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302

43034303
> Stability: 0 - Deprecated
43044304
4305-
Property for checking and controlling whether a FIPS compliant crypto provider
4306-
is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308-
This property is deprecated. Please use `crypto.setFips()` and
4309-
`crypto.getFips()` instead.
4305+
Deprecated property for checking and controlling [FIPS mode][]. Use
4306+
[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307

43114308
### `crypto.generateKey(type, options, callback)`
43124309

@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894
added: v10.0.0
48984895
-->
48994896

4900-
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901-
currently in use, `0` otherwise. A future semver-major release may change
4902-
the return type of this API to a {boolean}.
4897+
* Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+
semver-major release may change the return type of this API to a {boolean}.
4899+
4900+
With OpenSSL 3, this reports whether the default property query includes
4901+
`fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+
It can return `1` even when a requested cryptographic implementation cannot be
4903+
fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+
mode][].
49034905

49044906
### `crypto.getHashes()`
49054907

@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173
added: v10.0.0
61726174
-->
61736175

6174-
*`bool` {boolean} `true` to enable FIPS mode.
6176+
*`bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+
Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+
the default property query. It does not install, load, initialize, or validate
6180+
a FIPS provider. For a usable FIPS configuration, install the provider and
6181+
configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+
mode][].
6183+
6184+
If no loaded provider supplies a requested cryptographic implementation
6185+
matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+
return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+
operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+
not require a new fetch, including those using previously fetched
6189+
implementations or initialized operation contexts, may still succeed. Call this
6190+
method during application initialization, before application code uses other
6191+
OpenSSL-backed APIs.
6192+
6193+
This method only affects subsequent algorithm fetches. Node.js initializes some
6194+
OpenSSL state before application code runs. When the property query must be
6195+
active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+
configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+
flags additionally require a configured provider named `fips` to initialize and
6198+
pass its self-test; Node.js fails to start otherwise.
61756199

6176-
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177-
Throws an error if FIPS mode is not available.
6200+
Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+
disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+
enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203

61796204
### `crypto.sign(algorithm, data, key[, callback])`
61806205

@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634

66106635
### FIPS mode
66116636

6612-
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613-
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614-
installed by following the instructions in [OpenSSL's FIPS README file][].
6637+
Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+
is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+
provider and only applies when it is deployed according to its security policy.
6640+
Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+
follow the vendor's documentation for those builds.
66156642

6616-
For FIPS support in Node.js you will need:
6643+
With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+
With OpenSSL 3, FIPS support uses the provider model described in the
6646+
[OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647

66186648
* A correctly installed OpenSSL 3 FIPS provider.
66196649
* An OpenSSL 3 [FIPS module configuration file][].
6620-
* An OpenSSL 3 configuration file that references the FIPS module
6621-
configuration file.
6650+
* The FIPS provider to be loaded into the OpenSSL library context used by
6651+
Node.js, normally by activating it in an OpenSSL configuration file when
6652+
Node.js starts.
6653+
* The default property query to include `fips=yes` when cryptographic
6654+
implementations are fetched. This can be set from process startup by the
6655+
OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+
subsequent fetches by `crypto.setFips(true)`.
66226657

6623-
Node.js will need to be configured with an OpenSSL configuration file that
6624-
points to the FIPS provider. An example configuration file looks like this:
6658+
An example OpenSSL 3 configuration file looks like this:
66256659

66266660
```text
66276661
nodejs_conf = nodejs_init
6662+
config_diagnostics = 1
66286663
66296664
.include /<absolute path>/fipsmodule.cnf
66306665
66316666
[nodejs_init]
66326667
providers = provider_sect
6668+
alg_section = algorithm_sect
66336669
66346670
[provider_sect]
6635-
default = default_sect
66366671
# The fips section name should match the section name inside the
66376672
# included fipsmodule.cnf.
66386673
fips = fips_sect
6674+
base = base_sect
66396675
6640-
[default_sect]
6676+
[base_sect]
66416677
activate = 1
6642-
```
6643-
6644-
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645-
FIPS provider installation step:
66466678
6647-
```bash
6648-
openssl fipsinstall
6679+
[algorithm_sect]
6680+
default_properties = fips=yes
66496681
```
66506682

6651-
Set the `OPENSSL_CONF` environment variable to point to
6652-
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653-
provider dynamic library. e.g.
6683+
The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+
and contains module integrity and self-test information. The exact command and
6685+
arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+
[OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+
The example activates the provider and enables the `fips=yes` property query
6689+
when Node.js starts. To activate the provider at startup but enable the property
6690+
query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+
the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+
startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+
should be called before application code uses other OpenSSL-backed APIs. It is
6694+
not equivalent to enabling the property query from process startup because
6695+
Node.js initializes some OpenSSL state before application code runs. Use the
6696+
example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+
query must be active from process startup.
6698+
6699+
`config_diagnostics` causes configuration errors to prevent startup instead of
6700+
being ignored. The `base` provider supplies non-cryptographic supporting
6701+
algorithms, such as encoders and decoders, that are commonly needed alongside
6702+
the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+
algorithm selection to implementations that match `fips=yes`.
6704+
6705+
Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+
provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+
For example:
66546708

66556709
```bash
66566710
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712
```
66596713

6660-
FIPS mode can then be enabled in Node.js either by:
6661-
6662-
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663-
* Programmatically calling `crypto.setFips(true)`.
6664-
6665-
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666-
file. e.g.
6667-
6668-
```text
6669-
nodejs_conf = nodejs_init
6670-
6671-
.include /<absolute path>/fipsmodule.cnf
6672-
6673-
[nodejs_init]
6674-
providers = provider_sect
6675-
alg_section = algorithm_sect
6676-
6677-
[provider_sect]
6678-
default = default_sect
6679-
# The fips section name should match the section name inside the
6680-
# included fipsmodule.cnf.
6681-
fips = fips_sect
6682-
6683-
[default_sect]
6684-
activate = 1
6685-
6686-
[algorithm_sect]
6687-
default_properties = fips=yes
6688-
```
6714+
The [`--openssl-config`][] command-line option selects the configuration file and
6715+
takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+
configuration file is used.
6717+
6718+
By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+
`openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+
or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+
default section name.
6722+
6723+
On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+
startup. The following controls are also available:
6725+
6726+
*[`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+
additionally require the configured provider named `fips` to initialize and
6728+
pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+
prevents FIPS mode from being disabled from script code.
6730+
*[`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+
does not install, load, initialize, or validate a provider. Implementations
6732+
fetched before the call are not changed.
6733+
*[`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+
return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+
With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+
require a FIPS-capable OpenSSL build.
6738+
6739+
Only algorithms available under the active FIPS settings can be used. With
6740+
OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+
implementation matching `fips=yes`, fetching it fails, typically with
6742+
`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+
Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+
active FIPS settings.
6745+
6746+
OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+
of `libcrypto` in one process. This can affect native addons that load another
6748+
copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+
of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+
limitations][].
66896751

66906752
## Crypto constants
66916753

@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031
[Caveats]: #support-for-weak-or-compromised-algorithms
69707032
[Crypto constants]: #crypto-constants
6971-
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972-
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
7033+
[FIPS mode]: #fips-mode
7034+
[FIPS module configuration file]: https://docs.openssl.org/3.0/man5/fips_config/
69737035
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036
[JWK]: https://tools.ietf.org/html/rfc7517
69757037
[Key usages]: webcrypto.md#cryptokeyusages
69767038
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979-
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+
[OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+
[OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+
[OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045
[Permission Model]: permissions.md#permission-model
69827046
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057
[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058
[Web Crypto API documentation]: webcrypto.md
69957059
[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+
[`--enable-fips`]: cli.md#--enable-fips
7061+
[`--force-fips`]: cli.md#--force-fips
7062+
[`--openssl-config`]: cli.md#--openssl-configfile
7063+
[`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065
[`Buffer`]: buffer.md
69987066
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087
[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088
[`crypto.getCurves()`]: #cryptogetcurves
70217089
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+
[`crypto.getFips()`]: #cryptogetfips
70227091
[`crypto.getHashes()`]: #cryptogethashes
70237092
[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+
[`crypto.setFips()`]: #cryptosetfipsbool
70307100
[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101
[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit 9a256b0

Browse files
panvaaduh95
authored andcommitted
doc: clarify OpenSSL FIPS configuration
Distinguish OpenSSL 3 provider setup from FIPS/property-query state, document configuration precedence and provider limitations, and retain the OpenSSL 1.1 and runtime control guidance. Regenerate the CLI manpage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64982 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 28f662b commit 9a256b0

4 files changed

Lines changed: 164 additions & 87 deletions

File tree

β€ŽBUILDING.mdβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
10321032
### Configure OpenSSL appname
10331033

10341034
Node.js can use an OpenSSL configuration file by specifying the environment
1035-
variable `OPENSSL_CONF`, or using the command line option `--openssl-conf`, and
1036-
if none of those are specified will default to reading the default OpenSSL
1037-
configuration file `openssl.cnf`. Node.js will only read a section that is by
1038-
default named `nodejs_conf`, but this name can be overridden using the following
1039-
configure option:
1035+
variable `OPENSSL_CONF`, or using the command line option `--openssl-config`,
1036+
which takes precedence. If neither is specified, Node.js defaults to reading the
1037+
default OpenSSL configuration file `openssl.cnf`. Node.js will only read a
1038+
section that is by default named `nodejs_conf`, but this name can be overridden
1039+
using the following configure option:
10401040

10411041
```bash
10421042
./configure --openssl-conf-name=<some_conf_name>
@@ -1048,6 +1048,8 @@ Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
10481048
[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
10491049
It is not necessary to rebuild Node.js to enable support for FIPS.
10501050

1051+
When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
1052+
10511053
See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
10521054
enable FIPS support in Node.js.
10531055

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,9 @@ priority than `--dns-result-order`.
881881
added: v6.0.0
882882
-->
883883

884-
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
885-
against FIPS-compatible OpenSSL.)
884+
Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
885+
`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
886+
Node.js must be built against a FIPS-capable OpenSSL.
886887

887888
### `--enable-source-maps`
888889

@@ -1561,8 +1562,8 @@ Disable loading native addons that are not [context-aware][].
15611562
added: v6.0.0
15621563
-->
15631564

1564-
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
1565-
(Same requirements as `--enable-fips`.)
1565+
Enable [FIPS mode][] at startup and prevent it from being disabled from script
1566+
code. The same OpenSSL requirements as [`--enable-fips`][] apply.
15661567

15671568
### `--force-node-api-uncaught-exceptions-policy`
15681569

@@ -2257,9 +2258,11 @@ usually only useful for developers debugging Node.js itself.
22572258
added: v6.9.0
22582259
-->
22592260

2260-
Load an OpenSSL configuration file on startup. Among other uses, this can be
2261-
used to enable FIPS-compliant crypto if Node.js is built
2262-
against FIPS-enabled OpenSSL.
2261+
Load an OpenSSL configuration file on startup. The file can activate an
2262+
OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
2263+
[FIPS mode][].
2264+
2265+
This option takes precedence over the `OPENSSL_CONF` environment variable.
22632266

22642267
### `--openssl-legacy-provider`
22652268

@@ -4234,9 +4237,8 @@ environment variable is arbitrary.
42344237
added: v6.11.0
42354238
-->
42364239

4237-
Load an OpenSSL configuration file on startup. Among other uses, this can be
4238-
used to enable FIPS-compliant crypto if Node.js is built with
4239-
`./configure --openssl-fips`.
4240+
Load an OpenSSL configuration file on startup. The file can be used as part of
4241+
a [FIPS mode][] configuration.
42404242

42414243
If the [`--openssl-config`][] command-line option is used, the environment
42424244
variable is ignored.
@@ -4443,6 +4445,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44434445
[ECMAScript module]: esm.md#modules-ecmascript-modules
44444446
[EventSource Web API]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
44454447
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
4448+
[FIPS mode]: crypto.md#fips-mode
44464449
[File System Permissions]: permissions.md#file-system-permissions
44474450
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
44484451
[Module resolution and loading]: packages.md#module-resolution-and-loading
@@ -4472,6 +4475,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44724475
[`--cpu-prof-dir`]: #--cpu-prof-dir
44734476
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
44744477
[`--disable-sigusr1`]: #--disable-sigusr1
4478+
[`--enable-fips`]: #--enable-fips
44754479
[`--env-file-if-exists`]: #--env-file-if-existsfile
44764480
[`--env-file`]: #--env-filefile
44774481
[`--experimental-sea-config`]: single-executable-applications.md#1-generating-single-executable-preparation-blobs

β€Ždoc/api/crypto.mdβ€Ž

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302

43034303
> Stability: 0 - Deprecated
43044304
4305-
Property for checking and controlling whether a FIPS compliant crypto provider
4306-
is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308-
This property is deprecated. Please use `crypto.setFips()` and
4309-
`crypto.getFips()` instead.
4305+
Deprecated property for checking and controlling [FIPS mode][]. Use
4306+
[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307

43114308
### `crypto.generateKey(type, options, callback)`
43124309

@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894
added: v10.0.0
48984895
-->
48994896

4900-
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901-
currently in use, `0` otherwise. A future semver-major release may change
4902-
the return type of this API to a {boolean}.
4897+
* Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+
semver-major release may change the return type of this API to a {boolean}.
4899+
4900+
With OpenSSL 3, this reports whether the default property query includes
4901+
`fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+
It can return `1` even when a requested cryptographic implementation cannot be
4903+
fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+
mode][].
49034905

49044906
### `crypto.getHashes()`
49054907

@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173
added: v10.0.0
61726174
-->
61736175

6174-
*`bool` {boolean} `true` to enable FIPS mode.
6176+
*`bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+
Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+
the default property query. It does not install, load, initialize, or validate
6180+
a FIPS provider. For a usable FIPS configuration, install the provider and
6181+
configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+
mode][].
6183+
6184+
If no loaded provider supplies a requested cryptographic implementation
6185+
matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+
return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+
operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+
not require a new fetch, including those using previously fetched
6189+
implementations or initialized operation contexts, may still succeed. Call this
6190+
method during application initialization, before application code uses other
6191+
OpenSSL-backed APIs.
6192+
6193+
This method only affects subsequent algorithm fetches. Node.js initializes some
6194+
OpenSSL state before application code runs. When the property query must be
6195+
active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+
configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+
flags additionally require a configured provider named `fips` to initialize and
6198+
pass its self-test; Node.js fails to start otherwise.
61756199

6176-
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177-
Throws an error if FIPS mode is not available.
6200+
Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+
disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+
enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203

61796204
### `crypto.sign(algorithm, data, key[, callback])`
61806205

@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634

66106635
### FIPS mode
66116636

6612-
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613-
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614-
installed by following the instructions in [OpenSSL's FIPS README file][].
6637+
Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+
is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+
provider and only applies when it is deployed according to its security policy.
6640+
Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+
follow the vendor's documentation for those builds.
66156642

6616-
For FIPS support in Node.js you will need:
6643+
With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+
With OpenSSL 3, FIPS support uses the provider model described in the
6646+
[OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647

66186648
* A correctly installed OpenSSL 3 FIPS provider.
66196649
* An OpenSSL 3 [FIPS module configuration file][].
6620-
* An OpenSSL 3 configuration file that references the FIPS module
6621-
configuration file.
6650+
* The FIPS provider to be loaded into the OpenSSL library context used by
6651+
Node.js, normally by activating it in an OpenSSL configuration file when
6652+
Node.js starts.
6653+
* The default property query to include `fips=yes` when cryptographic
6654+
implementations are fetched. This can be set from process startup by the
6655+
OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+
subsequent fetches by `crypto.setFips(true)`.
66226657

6623-
Node.js will need to be configured with an OpenSSL configuration file that
6624-
points to the FIPS provider. An example configuration file looks like this:
6658+
An example OpenSSL 3 configuration file looks like this:
66256659

66266660
```text
66276661
nodejs_conf = nodejs_init
6662+
config_diagnostics = 1
66286663
66296664
.include /<absolute path>/fipsmodule.cnf
66306665
66316666
[nodejs_init]
66326667
providers = provider_sect
6668+
alg_section = algorithm_sect
66336669
66346670
[provider_sect]
6635-
default = default_sect
66366671
# The fips section name should match the section name inside the
66376672
# included fipsmodule.cnf.
66386673
fips = fips_sect
6674+
base = base_sect
66396675
6640-
[default_sect]
6676+
[base_sect]
66416677
activate = 1
6642-
```
6643-
6644-
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645-
FIPS provider installation step:
66466678
6647-
```bash
6648-
openssl fipsinstall
6679+
[algorithm_sect]
6680+
default_properties = fips=yes
66496681
```
66506682

6651-
Set the `OPENSSL_CONF` environment variable to point to
6652-
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653-
provider dynamic library. e.g.
6683+
The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+
and contains module integrity and self-test information. The exact command and
6685+
arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+
[OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+
The example activates the provider and enables the `fips=yes` property query
6689+
when Node.js starts. To activate the provider at startup but enable the property
6690+
query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+
the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+
startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+
should be called before application code uses other OpenSSL-backed APIs. It is
6694+
not equivalent to enabling the property query from process startup because
6695+
Node.js initializes some OpenSSL state before application code runs. Use the
6696+
example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+
query must be active from process startup.
6698+
6699+
`config_diagnostics` causes configuration errors to prevent startup instead of
6700+
being ignored. The `base` provider supplies non-cryptographic supporting
6701+
algorithms, such as encoders and decoders, that are commonly needed alongside
6702+
the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+
algorithm selection to implementations that match `fips=yes`.
6704+
6705+
Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+
provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+
For example:
66546708

66556709
```bash
66566710
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712
```
66596713

6660-
FIPS mode can then be enabled in Node.js either by:
6661-
6662-
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663-
* Programmatically calling `crypto.setFips(true)`.
6664-
6665-
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666-
file. e.g.
6667-
6668-
```text
6669-
nodejs_conf = nodejs_init
6670-
6671-
.include /<absolute path>/fipsmodule.cnf
6672-
6673-
[nodejs_init]
6674-
providers = provider_sect
6675-
alg_section = algorithm_sect
6676-
6677-
[provider_sect]
6678-
default = default_sect
6679-
# The fips section name should match the section name inside the
6680-
# included fipsmodule.cnf.
6681-
fips = fips_sect
6682-
6683-
[default_sect]
6684-
activate = 1
6685-
6686-
[algorithm_sect]
6687-
default_properties = fips=yes
6688-
```
6714+
The [`--openssl-config`][] command-line option selects the configuration file and
6715+
takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+
configuration file is used.
6717+
6718+
By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+
`openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+
or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+
default section name.
6722+
6723+
On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+
startup. The following controls are also available:
6725+
6726+
*[`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+
additionally require the configured provider named `fips` to initialize and
6728+
pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+
prevents FIPS mode from being disabled from script code.
6730+
*[`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+
does not install, load, initialize, or validate a provider. Implementations
6732+
fetched before the call are not changed.
6733+
*[`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+
return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+
With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+
require a FIPS-capable OpenSSL build.
6738+
6739+
Only algorithms available under the active FIPS settings can be used. With
6740+
OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+
implementation matching `fips=yes`, fetching it fails, typically with
6742+
`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+
Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+
active FIPS settings.
6745+
6746+
OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+
of `libcrypto` in one process. This can affect native addons that load another
6748+
copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+
of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+
limitations][].
66896751

66906752
## Crypto constants
66916753

@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031
[Caveats]: #support-for-weak-or-compromised-algorithms
69707032
[Crypto constants]: #crypto-constants
6971-
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972-
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
7033+
[FIPS mode]: #fips-mode
7034+
[FIPS module configuration file]: https://docs.openssl.org/3.0/man5/fips_config/
69737035
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036
[JWK]: https://tools.ietf.org/html/rfc7517
69757037
[Key usages]: webcrypto.md#cryptokeyusages
69767038
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979-
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+
[OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+
[OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+
[OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045
[Permission Model]: permissions.md#permission-model
69827046
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057
[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058
[Web Crypto API documentation]: webcrypto.md
69957059
[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+
[`--enable-fips`]: cli.md#--enable-fips
7061+
[`--force-fips`]: cli.md#--force-fips
7062+
[`--openssl-config`]: cli.md#--openssl-configfile
7063+
[`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065
[`Buffer`]: buffer.md
69987066
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087
[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088
[`crypto.getCurves()`]: #cryptogetcurves
70217089
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+
[`crypto.getFips()`]: #cryptogetfips
70227091
[`crypto.getHashes()`]: #cryptogethashes
70237092
[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+
[`crypto.setFips()`]: #cryptosetfipsbool
70307100
[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101
[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 9a256b0

Browse files
panvaaduh95
authored andcommitted
doc: clarify OpenSSL FIPS configuration
Distinguish OpenSSL 3 provider setup from FIPS/property-query state, document configuration precedence and provider limitations, and retain the OpenSSL 1.1 and runtime control guidance. Regenerate the CLI manpage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64982 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 28f662b commit 9a256b0

4 files changed

Lines changed: 164 additions & 87 deletions

File tree

β€ŽBUILDING.mdβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
10321032
### Configure OpenSSL appname
10331033

10341034
Node.js can use an OpenSSL configuration file by specifying the environment
1035-
variable `OPENSSL_CONF`, or using the command line option `--openssl-conf`, and
1036-
if none of those are specified will default to reading the default OpenSSL
1037-
configuration file `openssl.cnf`. Node.js will only read a section that is by
1038-
default named `nodejs_conf`, but this name can be overridden using the following
1039-
configure option:
1035+
variable `OPENSSL_CONF`, or using the command line option `--openssl-config`,
1036+
which takes precedence. If neither is specified, Node.js defaults to reading the
1037+
default OpenSSL configuration file `openssl.cnf`. Node.js will only read a
1038+
section that is by default named `nodejs_conf`, but this name can be overridden
1039+
using the following configure option:
10401040

10411041
```bash
10421042
./configure --openssl-conf-name=<some_conf_name>
@@ -1048,6 +1048,8 @@ Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
10481048
[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
10491049
It is not necessary to rebuild Node.js to enable support for FIPS.
10501050

1051+
When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
1052+
10511053
See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
10521054
enable FIPS support in Node.js.
10531055

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,9 @@ priority than `--dns-result-order`.
881881
added: v6.0.0
882882
-->
883883

884-
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
885-
against FIPS-compatible OpenSSL.)
884+
Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
885+
`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
886+
Node.js must be built against a FIPS-capable OpenSSL.
886887

887888
### `--enable-source-maps`
888889

@@ -1561,8 +1562,8 @@ Disable loading native addons that are not [context-aware][].
15611562
added: v6.0.0
15621563
-->
15631564

1564-
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
1565-
(Same requirements as `--enable-fips`.)
1565+
Enable [FIPS mode][] at startup and prevent it from being disabled from script
1566+
code. The same OpenSSL requirements as [`--enable-fips`][] apply.
15661567

15671568
### `--force-node-api-uncaught-exceptions-policy`
15681569

@@ -2257,9 +2258,11 @@ usually only useful for developers debugging Node.js itself.
22572258
added: v6.9.0
22582259
-->
22592260

2260-
Load an OpenSSL configuration file on startup. Among other uses, this can be
2261-
used to enable FIPS-compliant crypto if Node.js is built
2262-
against FIPS-enabled OpenSSL.
2261+
Load an OpenSSL configuration file on startup. The file can activate an
2262+
OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
2263+
[FIPS mode][].
2264+
2265+
This option takes precedence over the `OPENSSL_CONF` environment variable.
22632266

22642267
### `--openssl-legacy-provider`
22652268

@@ -4234,9 +4237,8 @@ environment variable is arbitrary.
42344237
added: v6.11.0
42354238
-->
42364239

4237-
Load an OpenSSL configuration file on startup. Among other uses, this can be
4238-
used to enable FIPS-compliant crypto if Node.js is built with
4239-
`./configure --openssl-fips`.
4240+
Load an OpenSSL configuration file on startup. The file can be used as part of
4241+
a [FIPS mode][] configuration.
42404242

42414243
If the [`--openssl-config`][] command-line option is used, the environment
42424244
variable is ignored.
@@ -4443,6 +4445,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44434445
[ECMAScript module]: esm.md#modules-ecmascript-modules
44444446
[EventSource Web API]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
44454447
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
4448+
[FIPS mode]: crypto.md#fips-mode
44464449
[File System Permissions]: permissions.md#file-system-permissions
44474450
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
44484451
[Module resolution and loading]: packages.md#module-resolution-and-loading
@@ -4472,6 +4475,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44724475
[`--cpu-prof-dir`]: #--cpu-prof-dir
44734476
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
44744477
[`--disable-sigusr1`]: #--disable-sigusr1
4478+
[`--enable-fips`]: #--enable-fips
44754479
[`--env-file-if-exists`]: #--env-file-if-existsfile
44764480
[`--env-file`]: #--env-filefile
44774481
[`--experimental-sea-config`]: single-executable-applications.md#1-generating-single-executable-preparation-blobs

β€Ždoc/api/crypto.mdβ€Ž

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302

43034303
> Stability: 0 - Deprecated
43044304
4305-
Property for checking and controlling whether a FIPS compliant crypto provider
4306-
is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308-
This property is deprecated. Please use `crypto.setFips()` and
4309-
`crypto.getFips()` instead.
4305+
Deprecated property for checking and controlling [FIPS mode][]. Use
4306+
[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307

43114308
### `crypto.generateKey(type, options, callback)`
43124309

@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894
added: v10.0.0
48984895
-->
48994896

4900-
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901-
currently in use, `0` otherwise. A future semver-major release may change
4902-
the return type of this API to a {boolean}.
4897+
* Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+
semver-major release may change the return type of this API to a {boolean}.
4899+
4900+
With OpenSSL 3, this reports whether the default property query includes
4901+
`fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+
It can return `1` even when a requested cryptographic implementation cannot be
4903+
fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+
mode][].
49034905

49044906
### `crypto.getHashes()`
49054907

@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173
added: v10.0.0
61726174
-->
61736175

6174-
*`bool` {boolean} `true` to enable FIPS mode.
6176+
*`bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+
Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+
the default property query. It does not install, load, initialize, or validate
6180+
a FIPS provider. For a usable FIPS configuration, install the provider and
6181+
configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+
mode][].
6183+
6184+
If no loaded provider supplies a requested cryptographic implementation
6185+
matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+
return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+
operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+
not require a new fetch, including those using previously fetched
6189+
implementations or initialized operation contexts, may still succeed. Call this
6190+
method during application initialization, before application code uses other
6191+
OpenSSL-backed APIs.
6192+
6193+
This method only affects subsequent algorithm fetches. Node.js initializes some
6194+
OpenSSL state before application code runs. When the property query must be
6195+
active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+
configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+
flags additionally require a configured provider named `fips` to initialize and
6198+
pass its self-test; Node.js fails to start otherwise.
61756199

6176-
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177-
Throws an error if FIPS mode is not available.
6200+
Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+
disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+
enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203

61796204
### `crypto.sign(algorithm, data, key[, callback])`
61806205

@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634

66106635
### FIPS mode
66116636

6612-
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613-
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614-
installed by following the instructions in [OpenSSL's FIPS README file][].
6637+
Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+
is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+
provider and only applies when it is deployed according to its security policy.
6640+
Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+
follow the vendor's documentation for those builds.
66156642

6616-
For FIPS support in Node.js you will need:
6643+
With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+
With OpenSSL 3, FIPS support uses the provider model described in the
6646+
[OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647

66186648
* A correctly installed OpenSSL 3 FIPS provider.
66196649
* An OpenSSL 3 [FIPS module configuration file][].
6620-
* An OpenSSL 3 configuration file that references the FIPS module
6621-
configuration file.
6650+
* The FIPS provider to be loaded into the OpenSSL library context used by
6651+
Node.js, normally by activating it in an OpenSSL configuration file when
6652+
Node.js starts.
6653+
* The default property query to include `fips=yes` when cryptographic
6654+
implementations are fetched. This can be set from process startup by the
6655+
OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+
subsequent fetches by `crypto.setFips(true)`.
66226657

6623-
Node.js will need to be configured with an OpenSSL configuration file that
6624-
points to the FIPS provider. An example configuration file looks like this:
6658+
An example OpenSSL 3 configuration file looks like this:
66256659

66266660
```text
66276661
nodejs_conf = nodejs_init
6662+
config_diagnostics = 1
66286663
66296664
.include /<absolute path>/fipsmodule.cnf
66306665
66316666
[nodejs_init]
66326667
providers = provider_sect
6668+
alg_section = algorithm_sect
66336669
66346670
[provider_sect]
6635-
default = default_sect
66366671
# The fips section name should match the section name inside the
66376672
# included fipsmodule.cnf.
66386673
fips = fips_sect
6674+
base = base_sect
66396675
6640-
[default_sect]
6676+
[base_sect]
66416677
activate = 1
6642-
```
6643-
6644-
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645-
FIPS provider installation step:
66466678
6647-
```bash
6648-
openssl fipsinstall
6679+
[algorithm_sect]
6680+
default_properties = fips=yes
66496681
```
66506682

6651-
Set the `OPENSSL_CONF` environment variable to point to
6652-
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653-
provider dynamic library. e.g.
6683+
The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+
and contains module integrity and self-test information. The exact command and
6685+
arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+
[OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+
The example activates the provider and enables the `fips=yes` property query
6689+
when Node.js starts. To activate the provider at startup but enable the property
6690+
query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+
the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+
startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+
should be called before application code uses other OpenSSL-backed APIs. It is
6694+
not equivalent to enabling the property query from process startup because
6695+
Node.js initializes some OpenSSL state before application code runs. Use the
6696+
example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+
query must be active from process startup.
6698+
6699+
`config_diagnostics` causes configuration errors to prevent startup instead of
6700+
being ignored. The `base` provider supplies non-cryptographic supporting
6701+
algorithms, such as encoders and decoders, that are commonly needed alongside
6702+
the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+
algorithm selection to implementations that match `fips=yes`.
6704+
6705+
Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+
provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+
For example:
66546708

66556709
```bash
66566710
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712
```
66596713

6660-
FIPS mode can then be enabled in Node.js either by:
6661-
6662-
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663-
* Programmatically calling `crypto.setFips(true)`.
6664-
6665-
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666-
file. e.g.
6667-
6668-
```text
6669-
nodejs_conf = nodejs_init
6670-
6671-
.include /<absolute path>/fipsmodule.cnf
6672-
6673-
[nodejs_init]
6674-
providers = provider_sect
6675-
alg_section = algorithm_sect
6676-
6677-
[provider_sect]
6678-
default = default_sect
6679-
# The fips section name should match the section name inside the
6680-
# included fipsmodule.cnf.
6681-
fips = fips_sect
6682-
6683-
[default_sect]
6684-
activate = 1
6685-
6686-
[algorithm_sect]
6687-
default_properties = fips=yes
6688-
```
6714+
The [`--openssl-config`][] command-line option selects the configuration file and
6715+
takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+
configuration file is used.
6717+
6718+
By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+
`openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+
or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+
default section name.
6722+
6723+
On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+
startup. The following controls are also available:
6725+
6726+
*[`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+
additionally require the configured provider named `fips` to initialize and
6728+
pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+
prevents FIPS mode from being disabled from script code.
6730+
*[`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+
does not install, load, initialize, or validate a provider. Implementations
6732+
fetched before the call are not changed.
6733+
*[`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+
return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+
With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+
require a FIPS-capable OpenSSL build.
6738+
6739+
Only algorithms available under the active FIPS settings can be used. With
6740+
OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+
implementation matching `fips=yes`, fetching it fails, typically with
6742+
`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+
Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+
active FIPS settings.
6745+
6746+
OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+
of `libcrypto` in one process. This can affect native addons that load another
6748+
copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+
of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+
limitations][].
66896751

66906752
## Crypto constants
66916753

@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031
[Caveats]: #support-for-weak-or-compromised-algorithms
69707032
[Crypto constants]: #crypto-constants
6971-
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972-
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
7033+
[FIPS mode]: #fips-mode
7034+
[FIPS module configuration file]: https://docs.openssl.org/3.0/man5/fips_config/
69737035
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036
[JWK]: https://tools.ietf.org/html/rfc7517
69757037
[Key usages]: webcrypto.md#cryptokeyusages
69767038
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979-
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+
[OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+
[OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+
[OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045
[Permission Model]: permissions.md#permission-model
69827046
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057
[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058
[Web Crypto API documentation]: webcrypto.md
69957059
[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+
[`--enable-fips`]: cli.md#--enable-fips
7061+
[`--force-fips`]: cli.md#--force-fips
7062+
[`--openssl-config`]: cli.md#--openssl-configfile
7063+
[`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065
[`Buffer`]: buffer.md
69987066
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087
[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088
[`crypto.getCurves()`]: #cryptogetcurves
70217089
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+
[`crypto.getFips()`]: #cryptogetfips
70227091
[`crypto.getHashes()`]: #cryptogethashes
70237092
[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+
[`crypto.setFips()`]: #cryptosetfipsbool
70307100
[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101
[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 9a256b0

Browse files
panvaaduh95
authored andcommitted
doc: clarify OpenSSL FIPS configuration
Distinguish OpenSSL 3 provider setup from FIPS/property-query state, document configuration precedence and provider limitations, and retain the OpenSSL 1.1 and runtime control guidance. Regenerate the CLI manpage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64982 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 28f662b commit 9a256b0

4 files changed

Lines changed: 164 additions & 87 deletions

File tree

β€ŽBUILDING.mdβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
10321032
### Configure OpenSSL appname
10331033

10341034
Node.js can use an OpenSSL configuration file by specifying the environment
1035-
variable `OPENSSL_CONF`, or using the command line option `--openssl-conf`, and
1036-
if none of those are specified will default to reading the default OpenSSL
1037-
configuration file `openssl.cnf`. Node.js will only read a section that is by
1038-
default named `nodejs_conf`, but this name can be overridden using the following
1039-
configure option:
1035+
variable `OPENSSL_CONF`, or using the command line option `--openssl-config`,
1036+
which takes precedence. If neither is specified, Node.js defaults to reading the
1037+
default OpenSSL configuration file `openssl.cnf`. Node.js will only read a
1038+
section that is by default named `nodejs_conf`, but this name can be overridden
1039+
using the following configure option:
10401040

10411041
```bash
10421042
./configure --openssl-conf-name=<some_conf_name>
@@ -1048,6 +1048,8 @@ Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
10481048
[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
10491049
It is not necessary to rebuild Node.js to enable support for FIPS.
10501050

1051+
When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
1052+
10511053
See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
10521054
enable FIPS support in Node.js.
10531055

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,9 @@ priority than `--dns-result-order`.
881881
added: v6.0.0
882882
-->
883883

884-
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
885-
against FIPS-compatible OpenSSL.)
884+
Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
885+
`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
886+
Node.js must be built against a FIPS-capable OpenSSL.
886887

887888
### `--enable-source-maps`
888889

@@ -1561,8 +1562,8 @@ Disable loading native addons that are not [context-aware][].
15611562
added: v6.0.0
15621563
-->
15631564

1564-
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
1565-
(Same requirements as `--enable-fips`.)
1565+
Enable [FIPS mode][] at startup and prevent it from being disabled from script
1566+
code. The same OpenSSL requirements as [`--enable-fips`][] apply.
15661567

15671568
### `--force-node-api-uncaught-exceptions-policy`
15681569

@@ -2257,9 +2258,11 @@ usually only useful for developers debugging Node.js itself.
22572258
added: v6.9.0
22582259
-->
22592260

2260-
Load an OpenSSL configuration file on startup. Among other uses, this can be
2261-
used to enable FIPS-compliant crypto if Node.js is built
2262-
against FIPS-enabled OpenSSL.
2261+
Load an OpenSSL configuration file on startup. The file can activate an
2262+
OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
2263+
[FIPS mode][].
2264+
2265+
This option takes precedence over the `OPENSSL_CONF` environment variable.
22632266

22642267
### `--openssl-legacy-provider`
22652268

@@ -4234,9 +4237,8 @@ environment variable is arbitrary.
42344237
added: v6.11.0
42354238
-->
42364239

4237-
Load an OpenSSL configuration file on startup. Among other uses, this can be
4238-
used to enable FIPS-compliant crypto if Node.js is built with
4239-
`./configure --openssl-fips`.
4240+
Load an OpenSSL configuration file on startup. The file can be used as part of
4241+
a [FIPS mode][] configuration.
42404242

42414243
If the [`--openssl-config`][] command-line option is used, the environment
42424244
variable is ignored.
@@ -4443,6 +4445,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44434445
[ECMAScript module]: esm.md#modules-ecmascript-modules
44444446
[EventSource Web API]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
44454447
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
4448+
[FIPS mode]: crypto.md#fips-mode
44464449
[File System Permissions]: permissions.md#file-system-permissions
44474450
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
44484451
[Module resolution and loading]: packages.md#module-resolution-and-loading
@@ -4472,6 +4475,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44724475
[`--cpu-prof-dir`]: #--cpu-prof-dir
44734476
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
44744477
[`--disable-sigusr1`]: #--disable-sigusr1
4478+
[`--enable-fips`]: #--enable-fips
44754479
[`--env-file-if-exists`]: #--env-file-if-existsfile
44764480
[`--env-file`]: #--env-filefile
44774481
[`--experimental-sea-config`]: single-executable-applications.md#1-generating-single-executable-preparation-blobs

β€Ždoc/api/crypto.mdβ€Ž

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302

43034303
> Stability: 0 - Deprecated
43044304
4305-
Property for checking and controlling whether a FIPS compliant crypto provider
4306-
is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308-
This property is deprecated. Please use `crypto.setFips()` and
4309-
`crypto.getFips()` instead.
4305+
Deprecated property for checking and controlling [FIPS mode][]. Use
4306+
[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307

43114308
### `crypto.generateKey(type, options, callback)`
43124309

@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894
added: v10.0.0
48984895
-->
48994896

4900-
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901-
currently in use, `0` otherwise. A future semver-major release may change
4902-
the return type of this API to a {boolean}.
4897+
* Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+
semver-major release may change the return type of this API to a {boolean}.
4899+
4900+
With OpenSSL 3, this reports whether the default property query includes
4901+
`fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+
It can return `1` even when a requested cryptographic implementation cannot be
4903+
fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+
mode][].
49034905

49044906
### `crypto.getHashes()`
49054907

@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173
added: v10.0.0
61726174
-->
61736175

6174-
*`bool` {boolean} `true` to enable FIPS mode.
6176+
*`bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+
Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+
the default property query. It does not install, load, initialize, or validate
6180+
a FIPS provider. For a usable FIPS configuration, install the provider and
6181+
configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+
mode][].
6183+
6184+
If no loaded provider supplies a requested cryptographic implementation
6185+
matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+
return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+
operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+
not require a new fetch, including those using previously fetched
6189+
implementations or initialized operation contexts, may still succeed. Call this
6190+
method during application initialization, before application code uses other
6191+
OpenSSL-backed APIs.
6192+
6193+
This method only affects subsequent algorithm fetches. Node.js initializes some
6194+
OpenSSL state before application code runs. When the property query must be
6195+
active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+
configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+
flags additionally require a configured provider named `fips` to initialize and
6198+
pass its self-test; Node.js fails to start otherwise.
61756199

6176-
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177-
Throws an error if FIPS mode is not available.
6200+
Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+
disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+
enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203

61796204
### `crypto.sign(algorithm, data, key[, callback])`
61806205

@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634

66106635
### FIPS mode
66116636

6612-
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613-
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614-
installed by following the instructions in [OpenSSL's FIPS README file][].
6637+
Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+
is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+
provider and only applies when it is deployed according to its security policy.
6640+
Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+
follow the vendor's documentation for those builds.
66156642

6616-
For FIPS support in Node.js you will need:
6643+
With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+
With OpenSSL 3, FIPS support uses the provider model described in the
6646+
[OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647

66186648
* A correctly installed OpenSSL 3 FIPS provider.
66196649
* An OpenSSL 3 [FIPS module configuration file][].
6620-
* An OpenSSL 3 configuration file that references the FIPS module
6621-
configuration file.
6650+
* The FIPS provider to be loaded into the OpenSSL library context used by
6651+
Node.js, normally by activating it in an OpenSSL configuration file when
6652+
Node.js starts.
6653+
* The default property query to include `fips=yes` when cryptographic
6654+
implementations are fetched. This can be set from process startup by the
6655+
OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+
subsequent fetches by `crypto.setFips(true)`.
66226657

6623-
Node.js will need to be configured with an OpenSSL configuration file that
6624-
points to the FIPS provider. An example configuration file looks like this:
6658+
An example OpenSSL 3 configuration file looks like this:
66256659

66266660
```text
66276661
nodejs_conf = nodejs_init
6662+
config_diagnostics = 1
66286663
66296664
.include /<absolute path>/fipsmodule.cnf
66306665
66316666
[nodejs_init]
66326667
providers = provider_sect
6668+
alg_section = algorithm_sect
66336669
66346670
[provider_sect]
6635-
default = default_sect
66366671
# The fips section name should match the section name inside the
66376672
# included fipsmodule.cnf.
66386673
fips = fips_sect
6674+
base = base_sect
66396675
6640-
[default_sect]
6676+
[base_sect]
66416677
activate = 1
6642-
```
6643-
6644-
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645-
FIPS provider installation step:
66466678
6647-
```bash
6648-
openssl fipsinstall
6679+
[algorithm_sect]
6680+
default_properties = fips=yes
66496681
```
66506682

6651-
Set the `OPENSSL_CONF` environment variable to point to
6652-
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653-
provider dynamic library. e.g.
6683+
The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+
and contains module integrity and self-test information. The exact command and
6685+
arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+
[OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+
The example activates the provider and enables the `fips=yes` property query
6689+
when Node.js starts. To activate the provider at startup but enable the property
6690+
query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+
the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+
startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+
should be called before application code uses other OpenSSL-backed APIs. It is
6694+
not equivalent to enabling the property query from process startup because
6695+
Node.js initializes some OpenSSL state before application code runs. Use the
6696+
example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+
query must be active from process startup.
6698+
6699+
`config_diagnostics` causes configuration errors to prevent startup instead of
6700+
being ignored. The `base` provider supplies non-cryptographic supporting
6701+
algorithms, such as encoders and decoders, that are commonly needed alongside
6702+
the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+
algorithm selection to implementations that match `fips=yes`.
6704+
6705+
Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+
provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+
For example:
66546708

66556709
```bash
66566710
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712
```
66596713

6660-
FIPS mode can then be enabled in Node.js either by:
6661-
6662-
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663-
* Programmatically calling `crypto.setFips(true)`.
6664-
6665-
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666-
file. e.g.
6667-
6668-
```text
6669-
nodejs_conf = nodejs_init
6670-
6671-
.include /<absolute path>/fipsmodule.cnf
6672-
6673-
[nodejs_init]
6674-
providers = provider_sect
6675-
alg_section = algorithm_sect
6676-
6677-
[provider_sect]
6678-
default = default_sect
6679-
# The fips section name should match the section name inside the
6680-
# included fipsmodule.cnf.
6681-
fips = fips_sect
6682-
6683-
[default_sect]
6684-
activate = 1
6685-
6686-
[algorithm_sect]
6687-
default_properties = fips=yes
6688-
```
6714+
The [`--openssl-config`][] command-line option selects the configuration file and
6715+
takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+
configuration file is used.
6717+
6718+
By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+
`openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+
or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+
default section name.
6722+
6723+
On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+
startup. The following controls are also available:
6725+
6726+
*[`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+
additionally require the configured provider named `fips` to initialize and
6728+
pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+
prevents FIPS mode from being disabled from script code.
6730+
*[`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+
does not install, load, initialize, or validate a provider. Implementations
6732+
fetched before the call are not changed.
6733+
*[`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+
return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+
With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+
require a FIPS-capable OpenSSL build.
6738+
6739+
Only algorithms available under the active FIPS settings can be used. With
6740+
OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+
implementation matching `fips=yes`, fetching it fails, typically with
6742+
`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+
Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+
active FIPS settings.
6745+
6746+
OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+
of `libcrypto` in one process. This can affect native addons that load another
6748+
copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+
of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+
limitations][].
66896751

66906752
## Crypto constants
66916753

@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031
[Caveats]: #support-for-weak-or-compromised-algorithms
69707032
[Crypto constants]: #crypto-constants
6971-
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972-
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
7033+
[FIPS mode]: #fips-mode
7034+
[FIPS module configuration file]: https://docs.openssl.org/3.0/man5/fips_config/
69737035
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036
[JWK]: https://tools.ietf.org/html/rfc7517
69757037
[Key usages]: webcrypto.md#cryptokeyusages
69767038
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979-
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+
[OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+
[OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+
[OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045
[Permission Model]: permissions.md#permission-model
69827046
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057
[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058
[Web Crypto API documentation]: webcrypto.md
69957059
[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+
[`--enable-fips`]: cli.md#--enable-fips
7061+
[`--force-fips`]: cli.md#--force-fips
7062+
[`--openssl-config`]: cli.md#--openssl-configfile
7063+
[`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065
[`Buffer`]: buffer.md
69987066
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087
[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088
[`crypto.getCurves()`]: #cryptogetcurves
70217089
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+
[`crypto.getFips()`]: #cryptogetfips
70227091
[`crypto.getHashes()`]: #cryptogethashes
70237092
[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+
[`crypto.setFips()`]: #cryptosetfipsbool
70307100
[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101
[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit 9a256b0

Browse files
panvaaduh95
authored andcommitted
doc: clarify OpenSSL FIPS configuration
Distinguish OpenSSL 3 provider setup from FIPS/property-query state, document configuration precedence and provider limitations, and retain the OpenSSL 1.1 and runtime control guidance. Regenerate the CLI manpage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64982 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 28f662b commit 9a256b0

4 files changed

Lines changed: 164 additions & 87 deletions

File tree

β€ŽBUILDING.mdβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
10321032
### Configure OpenSSL appname
10331033

10341034
Node.js can use an OpenSSL configuration file by specifying the environment
1035-
variable `OPENSSL_CONF`, or using the command line option `--openssl-conf`, and
1036-
if none of those are specified will default to reading the default OpenSSL
1037-
configuration file `openssl.cnf`. Node.js will only read a section that is by
1038-
default named `nodejs_conf`, but this name can be overridden using the following
1039-
configure option:
1035+
variable `OPENSSL_CONF`, or using the command line option `--openssl-config`,
1036+
which takes precedence. If neither is specified, Node.js defaults to reading the
1037+
default OpenSSL configuration file `openssl.cnf`. Node.js will only read a
1038+
section that is by default named `nodejs_conf`, but this name can be overridden
1039+
using the following configure option:
10401040

10411041
```bash
10421042
./configure --openssl-conf-name=<some_conf_name>
@@ -1048,6 +1048,8 @@ Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
10481048
[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
10491049
It is not necessary to rebuild Node.js to enable support for FIPS.
10501050

1051+
When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
1052+
10511053
See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
10521054
enable FIPS support in Node.js.
10531055

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,9 @@ priority than `--dns-result-order`.
881881
added: v6.0.0
882882
-->
883883

884-
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
885-
against FIPS-compatible OpenSSL.)
884+
Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
885+
`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
886+
Node.js must be built against a FIPS-capable OpenSSL.
886887

887888
### `--enable-source-maps`
888889

@@ -1561,8 +1562,8 @@ Disable loading native addons that are not [context-aware][].
15611562
added: v6.0.0
15621563
-->
15631564

1564-
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
1565-
(Same requirements as `--enable-fips`.)
1565+
Enable [FIPS mode][] at startup and prevent it from being disabled from script
1566+
code. The same OpenSSL requirements as [`--enable-fips`][] apply.
15661567

15671568
### `--force-node-api-uncaught-exceptions-policy`
15681569

@@ -2257,9 +2258,11 @@ usually only useful for developers debugging Node.js itself.
22572258
added: v6.9.0
22582259
-->
22592260

2260-
Load an OpenSSL configuration file on startup. Among other uses, this can be
2261-
used to enable FIPS-compliant crypto if Node.js is built
2262-
against FIPS-enabled OpenSSL.
2261+
Load an OpenSSL configuration file on startup. The file can activate an
2262+
OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
2263+
[FIPS mode][].
2264+
2265+
This option takes precedence over the `OPENSSL_CONF` environment variable.
22632266

22642267
### `--openssl-legacy-provider`
22652268

@@ -4234,9 +4237,8 @@ environment variable is arbitrary.
42344237
added: v6.11.0
42354238
-->
42364239

4237-
Load an OpenSSL configuration file on startup. Among other uses, this can be
4238-
used to enable FIPS-compliant crypto if Node.js is built with
4239-
`./configure --openssl-fips`.
4240+
Load an OpenSSL configuration file on startup. The file can be used as part of
4241+
a [FIPS mode][] configuration.
42404242

42414243
If the [`--openssl-config`][] command-line option is used, the environment
42424244
variable is ignored.
@@ -4443,6 +4445,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44434445
[ECMAScript module]: esm.md#modules-ecmascript-modules
44444446
[EventSource Web API]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
44454447
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
4448+
[FIPS mode]: crypto.md#fips-mode
44464449
[File System Permissions]: permissions.md#file-system-permissions
44474450
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
44484451
[Module resolution and loading]: packages.md#module-resolution-and-loading
@@ -4472,6 +4475,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44724475
[`--cpu-prof-dir`]: #--cpu-prof-dir
44734476
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
44744477
[`--disable-sigusr1`]: #--disable-sigusr1
4478+
[`--enable-fips`]: #--enable-fips
44754479
[`--env-file-if-exists`]: #--env-file-if-existsfile
44764480
[`--env-file`]: #--env-filefile
44774481
[`--experimental-sea-config`]: single-executable-applications.md#1-generating-single-executable-preparation-blobs

β€Ždoc/api/crypto.mdβ€Ž

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302

43034303
> Stability: 0 - Deprecated
43044304
4305-
Property for checking and controlling whether a FIPS compliant crypto provider
4306-
is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308-
This property is deprecated. Please use `crypto.setFips()` and
4309-
`crypto.getFips()` instead.
4305+
Deprecated property for checking and controlling [FIPS mode][]. Use
4306+
[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307

43114308
### `crypto.generateKey(type, options, callback)`
43124309

@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894
added: v10.0.0
48984895
-->
48994896

4900-
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901-
currently in use, `0` otherwise. A future semver-major release may change
4902-
the return type of this API to a {boolean}.
4897+
* Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+
semver-major release may change the return type of this API to a {boolean}.
4899+
4900+
With OpenSSL 3, this reports whether the default property query includes
4901+
`fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+
It can return `1` even when a requested cryptographic implementation cannot be
4903+
fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+
mode][].
49034905

49044906
### `crypto.getHashes()`
49054907

@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173
added: v10.0.0
61726174
-->
61736175

6174-
*`bool` {boolean} `true` to enable FIPS mode.
6176+
*`bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+
Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+
the default property query. It does not install, load, initialize, or validate
6180+
a FIPS provider. For a usable FIPS configuration, install the provider and
6181+
configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+
mode][].
6183+
6184+
If no loaded provider supplies a requested cryptographic implementation
6185+
matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+
return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+
operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+
not require a new fetch, including those using previously fetched
6189+
implementations or initialized operation contexts, may still succeed. Call this
6190+
method during application initialization, before application code uses other
6191+
OpenSSL-backed APIs.
6192+
6193+
This method only affects subsequent algorithm fetches. Node.js initializes some
6194+
OpenSSL state before application code runs. When the property query must be
6195+
active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+
configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+
flags additionally require a configured provider named `fips` to initialize and
6198+
pass its self-test; Node.js fails to start otherwise.
61756199

6176-
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177-
Throws an error if FIPS mode is not available.
6200+
Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+
disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+
enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203

61796204
### `crypto.sign(algorithm, data, key[, callback])`
61806205

@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634

66106635
### FIPS mode
66116636

6612-
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613-
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614-
installed by following the instructions in [OpenSSL's FIPS README file][].
6637+
Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+
is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+
provider and only applies when it is deployed according to its security policy.
6640+
Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+
follow the vendor's documentation for those builds.
66156642

6616-
For FIPS support in Node.js you will need:
6643+
With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+
With OpenSSL 3, FIPS support uses the provider model described in the
6646+
[OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647

66186648
* A correctly installed OpenSSL 3 FIPS provider.
66196649
* An OpenSSL 3 [FIPS module configuration file][].
6620-
* An OpenSSL 3 configuration file that references the FIPS module
6621-
configuration file.
6650+
* The FIPS provider to be loaded into the OpenSSL library context used by
6651+
Node.js, normally by activating it in an OpenSSL configuration file when
6652+
Node.js starts.
6653+
* The default property query to include `fips=yes` when cryptographic
6654+
implementations are fetched. This can be set from process startup by the
6655+
OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+
subsequent fetches by `crypto.setFips(true)`.
66226657

6623-
Node.js will need to be configured with an OpenSSL configuration file that
6624-
points to the FIPS provider. An example configuration file looks like this:
6658+
An example OpenSSL 3 configuration file looks like this:
66256659

66266660
```text
66276661
nodejs_conf = nodejs_init
6662+
config_diagnostics = 1
66286663
66296664
.include /<absolute path>/fipsmodule.cnf
66306665
66316666
[nodejs_init]
66326667
providers = provider_sect
6668+
alg_section = algorithm_sect
66336669
66346670
[provider_sect]
6635-
default = default_sect
66366671
# The fips section name should match the section name inside the
66376672
# included fipsmodule.cnf.
66386673
fips = fips_sect
6674+
base = base_sect
66396675
6640-
[default_sect]
6676+
[base_sect]
66416677
activate = 1
6642-
```
6643-
6644-
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645-
FIPS provider installation step:
66466678
6647-
```bash
6648-
openssl fipsinstall
6679+
[algorithm_sect]
6680+
default_properties = fips=yes
66496681
```
66506682

6651-
Set the `OPENSSL_CONF` environment variable to point to
6652-
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653-
provider dynamic library. e.g.
6683+
The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+
and contains module integrity and self-test information. The exact command and
6685+
arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+
[OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+
The example activates the provider and enables the `fips=yes` property query
6689+
when Node.js starts. To activate the provider at startup but enable the property
6690+
query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+
the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+
startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+
should be called before application code uses other OpenSSL-backed APIs. It is
6694+
not equivalent to enabling the property query from process startup because
6695+
Node.js initializes some OpenSSL state before application code runs. Use the
6696+
example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+
query must be active from process startup.
6698+
6699+
`config_diagnostics` causes configuration errors to prevent startup instead of
6700+
being ignored. The `base` provider supplies non-cryptographic supporting
6701+
algorithms, such as encoders and decoders, that are commonly needed alongside
6702+
the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+
algorithm selection to implementations that match `fips=yes`.
6704+
6705+
Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+
provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+
For example:
66546708

66556709
```bash
66566710
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712
```
66596713

6660-
FIPS mode can then be enabled in Node.js either by:
6661-
6662-
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663-
* Programmatically calling `crypto.setFips(true)`.
6664-
6665-
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666-
file. e.g.
6667-
6668-
```text
6669-
nodejs_conf = nodejs_init
6670-
6671-
.include /<absolute path>/fipsmodule.cnf
6672-
6673-
[nodejs_init]
6674-
providers = provider_sect
6675-
alg_section = algorithm_sect
6676-
6677-
[provider_sect]
6678-
default = default_sect
6679-
# The fips section name should match the section name inside the
6680-
# included fipsmodule.cnf.
6681-
fips = fips_sect
6682-
6683-
[default_sect]
6684-
activate = 1
6685-
6686-
[algorithm_sect]
6687-
default_properties = fips=yes
6688-
```
6714+
The [`--openssl-config`][] command-line option selects the configuration file and
6715+
takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+
configuration file is used.
6717+
6718+
By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+
`openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+
or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+
default section name.
6722+
6723+
On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+
startup. The following controls are also available:
6725+
6726+
*[`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+
additionally require the configured provider named `fips` to initialize and
6728+
pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+
prevents FIPS mode from being disabled from script code.
6730+
*[`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+
does not install, load, initialize, or validate a provider. Implementations
6732+
fetched before the call are not changed.
6733+
*[`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+
return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+
With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+
require a FIPS-capable OpenSSL build.
6738+
6739+
Only algorithms available under the active FIPS settings can be used. With
6740+
OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+
implementation matching `fips=yes`, fetching it fails, typically with
6742+
`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+
Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+
active FIPS settings.
6745+
6746+
OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+
of `libcrypto` in one process. This can affect native addons that load another
6748+
copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+
of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+
limitations][].
66896751

66906752
## Crypto constants
66916753

@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031
[Caveats]: #support-for-weak-or-compromised-algorithms
69707032
[Crypto constants]: #crypto-constants
6971-
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972-
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
7033+
[FIPS mode]: #fips-mode
7034+
[FIPS module configuration file]: https://docs.openssl.org/3.0/man5/fips_config/
69737035
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036
[JWK]: https://tools.ietf.org/html/rfc7517
69757037
[Key usages]: webcrypto.md#cryptokeyusages
69767038
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979-
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+
[OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+
[OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+
[OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045
[Permission Model]: permissions.md#permission-model
69827046
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057
[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058
[Web Crypto API documentation]: webcrypto.md
69957059
[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+
[`--enable-fips`]: cli.md#--enable-fips
7061+
[`--force-fips`]: cli.md#--force-fips
7062+
[`--openssl-config`]: cli.md#--openssl-configfile
7063+
[`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065
[`Buffer`]: buffer.md
69987066
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087
[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088
[`crypto.getCurves()`]: #cryptogetcurves
70217089
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+
[`crypto.getFips()`]: #cryptogetfips
70227091
[`crypto.getHashes()`]: #cryptogethashes
70237092
[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+
[`crypto.setFips()`]: #cryptosetfipsbool
70307100
[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101
[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 9a256b0

Browse files
panvaaduh95
authored andcommitted
doc: clarify OpenSSL FIPS configuration
Distinguish OpenSSL 3 provider setup from FIPS/property-query state, document configuration precedence and provider limitations, and retain the OpenSSL 1.1 and runtime control guidance. Regenerate the CLI manpage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64982 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 28f662b commit 9a256b0

4 files changed

Lines changed: 164 additions & 87 deletions

File tree

β€ŽBUILDING.mdβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
10321032
### Configure OpenSSL appname
10331033

10341034
Node.js can use an OpenSSL configuration file by specifying the environment
1035-
variable `OPENSSL_CONF`, or using the command line option `--openssl-conf`, and
1036-
if none of those are specified will default to reading the default OpenSSL
1037-
configuration file `openssl.cnf`. Node.js will only read a section that is by
1038-
default named `nodejs_conf`, but this name can be overridden using the following
1039-
configure option:
1035+
variable `OPENSSL_CONF`, or using the command line option `--openssl-config`,
1036+
which takes precedence. If neither is specified, Node.js defaults to reading the
1037+
default OpenSSL configuration file `openssl.cnf`. Node.js will only read a
1038+
section that is by default named `nodejs_conf`, but this name can be overridden
1039+
using the following configure option:
10401040

10411041
```bash
10421042
./configure --openssl-conf-name=<some_conf_name>
@@ -1048,6 +1048,8 @@ Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
10481048
[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
10491049
It is not necessary to rebuild Node.js to enable support for FIPS.
10501050

1051+
When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
1052+
10511053
See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
10521054
enable FIPS support in Node.js.
10531055

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,9 @@ priority than `--dns-result-order`.
881881
added: v6.0.0
882882
-->
883883

884-
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
885-
against FIPS-compatible OpenSSL.)
884+
Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
885+
`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
886+
Node.js must be built against a FIPS-capable OpenSSL.
886887

887888
### `--enable-source-maps`
888889

@@ -1561,8 +1562,8 @@ Disable loading native addons that are not [context-aware][].
15611562
added: v6.0.0
15621563
-->
15631564

1564-
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
1565-
(Same requirements as `--enable-fips`.)
1565+
Enable [FIPS mode][] at startup and prevent it from being disabled from script
1566+
code. The same OpenSSL requirements as [`--enable-fips`][] apply.
15661567

15671568
### `--force-node-api-uncaught-exceptions-policy`
15681569

@@ -2257,9 +2258,11 @@ usually only useful for developers debugging Node.js itself.
22572258
added: v6.9.0
22582259
-->
22592260

2260-
Load an OpenSSL configuration file on startup. Among other uses, this can be
2261-
used to enable FIPS-compliant crypto if Node.js is built
2262-
against FIPS-enabled OpenSSL.
2261+
Load an OpenSSL configuration file on startup. The file can activate an
2262+
OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
2263+
[FIPS mode][].
2264+
2265+
This option takes precedence over the `OPENSSL_CONF` environment variable.
22632266

22642267
### `--openssl-legacy-provider`
22652268

@@ -4234,9 +4237,8 @@ environment variable is arbitrary.
42344237
added: v6.11.0
42354238
-->
42364239

4237-
Load an OpenSSL configuration file on startup. Among other uses, this can be
4238-
used to enable FIPS-compliant crypto if Node.js is built with
4239-
`./configure --openssl-fips`.
4240+
Load an OpenSSL configuration file on startup. The file can be used as part of
4241+
a [FIPS mode][] configuration.
42404242

42414243
If the [`--openssl-config`][] command-line option is used, the environment
42424244
variable is ignored.
@@ -4443,6 +4445,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44434445
[ECMAScript module]: esm.md#modules-ecmascript-modules
44444446
[EventSource Web API]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
44454447
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
4448+
[FIPS mode]: crypto.md#fips-mode
44464449
[File System Permissions]: permissions.md#file-system-permissions
44474450
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
44484451
[Module resolution and loading]: packages.md#module-resolution-and-loading
@@ -4472,6 +4475,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44724475
[`--cpu-prof-dir`]: #--cpu-prof-dir
44734476
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
44744477
[`--disable-sigusr1`]: #--disable-sigusr1
4478+
[`--enable-fips`]: #--enable-fips
44754479
[`--env-file-if-exists`]: #--env-file-if-existsfile
44764480
[`--env-file`]: #--env-filefile
44774481
[`--experimental-sea-config`]: single-executable-applications.md#1-generating-single-executable-preparation-blobs

β€Ždoc/api/crypto.mdβ€Ž

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302

43034303
> Stability: 0 - Deprecated
43044304
4305-
Property for checking and controlling whether a FIPS compliant crypto provider
4306-
is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308-
This property is deprecated. Please use `crypto.setFips()` and
4309-
`crypto.getFips()` instead.
4305+
Deprecated property for checking and controlling [FIPS mode][]. Use
4306+
[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307

43114308
### `crypto.generateKey(type, options, callback)`
43124309

@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894
added: v10.0.0
48984895
-->
48994896

4900-
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901-
currently in use, `0` otherwise. A future semver-major release may change
4902-
the return type of this API to a {boolean}.
4897+
* Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+
semver-major release may change the return type of this API to a {boolean}.
4899+
4900+
With OpenSSL 3, this reports whether the default property query includes
4901+
`fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+
It can return `1` even when a requested cryptographic implementation cannot be
4903+
fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+
mode][].
49034905

49044906
### `crypto.getHashes()`
49054907

@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173
added: v10.0.0
61726174
-->
61736175

6174-
*`bool` {boolean} `true` to enable FIPS mode.
6176+
*`bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+
Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+
the default property query. It does not install, load, initialize, or validate
6180+
a FIPS provider. For a usable FIPS configuration, install the provider and
6181+
configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+
mode][].
6183+
6184+
If no loaded provider supplies a requested cryptographic implementation
6185+
matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+
return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+
operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+
not require a new fetch, including those using previously fetched
6189+
implementations or initialized operation contexts, may still succeed. Call this
6190+
method during application initialization, before application code uses other
6191+
OpenSSL-backed APIs.
6192+
6193+
This method only affects subsequent algorithm fetches. Node.js initializes some
6194+
OpenSSL state before application code runs. When the property query must be
6195+
active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+
configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+
flags additionally require a configured provider named `fips` to initialize and
6198+
pass its self-test; Node.js fails to start otherwise.
61756199

6176-
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177-
Throws an error if FIPS mode is not available.
6200+
Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+
disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+
enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203

61796204
### `crypto.sign(algorithm, data, key[, callback])`
61806205

@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634

66106635
### FIPS mode
66116636

6612-
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613-
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614-
installed by following the instructions in [OpenSSL's FIPS README file][].
6637+
Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+
is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+
provider and only applies when it is deployed according to its security policy.
6640+
Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+
follow the vendor's documentation for those builds.
66156642

6616-
For FIPS support in Node.js you will need:
6643+
With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+
With OpenSSL 3, FIPS support uses the provider model described in the
6646+
[OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647

66186648
* A correctly installed OpenSSL 3 FIPS provider.
66196649
* An OpenSSL 3 [FIPS module configuration file][].
6620-
* An OpenSSL 3 configuration file that references the FIPS module
6621-
configuration file.
6650+
* The FIPS provider to be loaded into the OpenSSL library context used by
6651+
Node.js, normally by activating it in an OpenSSL configuration file when
6652+
Node.js starts.
6653+
* The default property query to include `fips=yes` when cryptographic
6654+
implementations are fetched. This can be set from process startup by the
6655+
OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+
subsequent fetches by `crypto.setFips(true)`.
66226657

6623-
Node.js will need to be configured with an OpenSSL configuration file that
6624-
points to the FIPS provider. An example configuration file looks like this:
6658+
An example OpenSSL 3 configuration file looks like this:
66256659

66266660
```text
66276661
nodejs_conf = nodejs_init
6662+
config_diagnostics = 1
66286663
66296664
.include /<absolute path>/fipsmodule.cnf
66306665
66316666
[nodejs_init]
66326667
providers = provider_sect
6668+
alg_section = algorithm_sect
66336669
66346670
[provider_sect]
6635-
default = default_sect
66366671
# The fips section name should match the section name inside the
66376672
# included fipsmodule.cnf.
66386673
fips = fips_sect
6674+
base = base_sect
66396675
6640-
[default_sect]
6676+
[base_sect]
66416677
activate = 1
6642-
```
6643-
6644-
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645-
FIPS provider installation step:
66466678
6647-
```bash
6648-
openssl fipsinstall
6679+
[algorithm_sect]
6680+
default_properties = fips=yes
66496681
```
66506682

6651-
Set the `OPENSSL_CONF` environment variable to point to
6652-
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653-
provider dynamic library. e.g.
6683+
The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+
and contains module integrity and self-test information. The exact command and
6685+
arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+
[OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+
The example activates the provider and enables the `fips=yes` property query
6689+
when Node.js starts. To activate the provider at startup but enable the property
6690+
query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+
the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+
startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+
should be called before application code uses other OpenSSL-backed APIs. It is
6694+
not equivalent to enabling the property query from process startup because
6695+
Node.js initializes some OpenSSL state before application code runs. Use the
6696+
example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+
query must be active from process startup.
6698+
6699+
`config_diagnostics` causes configuration errors to prevent startup instead of
6700+
being ignored. The `base` provider supplies non-cryptographic supporting
6701+
algorithms, such as encoders and decoders, that are commonly needed alongside
6702+
the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+
algorithm selection to implementations that match `fips=yes`.
6704+
6705+
Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+
provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+
For example:
66546708

66556709
```bash
66566710
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712
```
66596713

6660-
FIPS mode can then be enabled in Node.js either by:
6661-
6662-
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663-
* Programmatically calling `crypto.setFips(true)`.
6664-
6665-
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666-
file. e.g.
6667-
6668-
```text
6669-
nodejs_conf = nodejs_init
6670-
6671-
.include /<absolute path>/fipsmodule.cnf
6672-
6673-
[nodejs_init]
6674-
providers = provider_sect
6675-
alg_section = algorithm_sect
6676-
6677-
[provider_sect]
6678-
default = default_sect
6679-
# The fips section name should match the section name inside the
6680-
# included fipsmodule.cnf.
6681-
fips = fips_sect
6682-
6683-
[default_sect]
6684-
activate = 1
6685-
6686-
[algorithm_sect]
6687-
default_properties = fips=yes
6688-
```
6714+
The [`--openssl-config`][] command-line option selects the configuration file and
6715+
takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+
configuration file is used.
6717+
6718+
By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+
`openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+
or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+
default section name.
6722+
6723+
On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+
startup. The following controls are also available:
6725+
6726+
*[`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+
additionally require the configured provider named `fips` to initialize and
6728+
pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+
prevents FIPS mode from being disabled from script code.
6730+
*[`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+
does not install, load, initialize, or validate a provider. Implementations
6732+
fetched before the call are not changed.
6733+
*[`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+
return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+
With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+
require a FIPS-capable OpenSSL build.
6738+
6739+
Only algorithms available under the active FIPS settings can be used. With
6740+
OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+
implementation matching `fips=yes`, fetching it fails, typically with
6742+
`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+
Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+
active FIPS settings.
6745+
6746+
OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+
of `libcrypto` in one process. This can affect native addons that load another
6748+
copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+
of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+
limitations][].
66896751

66906752
## Crypto constants
66916753

@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031
[Caveats]: #support-for-weak-or-compromised-algorithms
69707032
[Crypto constants]: #crypto-constants
6971-
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972-
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
7033+
[FIPS mode]: #fips-mode
7034+
[FIPS module configuration file]: https://docs.openssl.org/3.0/man5/fips_config/
69737035
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036
[JWK]: https://tools.ietf.org/html/rfc7517
69757037
[Key usages]: webcrypto.md#cryptokeyusages
69767038
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979-
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+
[OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+
[OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+
[OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045
[Permission Model]: permissions.md#permission-model
69827046
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057
[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058
[Web Crypto API documentation]: webcrypto.md
69957059
[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+
[`--enable-fips`]: cli.md#--enable-fips
7061+
[`--force-fips`]: cli.md#--force-fips
7062+
[`--openssl-config`]: cli.md#--openssl-configfile
7063+
[`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065
[`Buffer`]: buffer.md
69987066
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087
[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088
[`crypto.getCurves()`]: #cryptogetcurves
70217089
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+
[`crypto.getFips()`]: #cryptogetfips
70227091
[`crypto.getHashes()`]: #cryptogethashes
70237092
[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+
[`crypto.setFips()`]: #cryptosetfipsbool
70307100
[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101
[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 9a256b0

Browse files
panvaaduh95
authored andcommitted
doc: clarify OpenSSL FIPS configuration
Distinguish OpenSSL 3 provider setup from FIPS/property-query state, document configuration precedence and provider limitations, and retain the OpenSSL 1.1 and runtime control guidance. Regenerate the CLI manpage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64982 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 28f662b commit 9a256b0

4 files changed

Lines changed: 164 additions & 87 deletions

File tree

β€ŽBUILDING.mdβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
10321032
### Configure OpenSSL appname
10331033

10341034
Node.js can use an OpenSSL configuration file by specifying the environment
1035-
variable `OPENSSL_CONF`, or using the command line option `--openssl-conf`, and
1036-
if none of those are specified will default to reading the default OpenSSL
1037-
configuration file `openssl.cnf`. Node.js will only read a section that is by
1038-
default named `nodejs_conf`, but this name can be overridden using the following
1039-
configure option:
1035+
variable `OPENSSL_CONF`, or using the command line option `--openssl-config`,
1036+
which takes precedence. If neither is specified, Node.js defaults to reading the
1037+
default OpenSSL configuration file `openssl.cnf`. Node.js will only read a
1038+
section that is by default named `nodejs_conf`, but this name can be overridden
1039+
using the following configure option:
10401040

10411041
```bash
10421042
./configure --openssl-conf-name=<some_conf_name>
@@ -1048,6 +1048,8 @@ Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
10481048
[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
10491049
It is not necessary to rebuild Node.js to enable support for FIPS.
10501050

1051+
When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
1052+
10511053
See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
10521054
enable FIPS support in Node.js.
10531055

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,9 @@ priority than `--dns-result-order`.
881881
added: v6.0.0
882882
-->
883883

884-
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
885-
against FIPS-compatible OpenSSL.)
884+
Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
885+
`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
886+
Node.js must be built against a FIPS-capable OpenSSL.
886887

887888
### `--enable-source-maps`
888889

@@ -1561,8 +1562,8 @@ Disable loading native addons that are not [context-aware][].
15611562
added: v6.0.0
15621563
-->
15631564

1564-
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
1565-
(Same requirements as `--enable-fips`.)
1565+
Enable [FIPS mode][] at startup and prevent it from being disabled from script
1566+
code. The same OpenSSL requirements as [`--enable-fips`][] apply.
15661567

15671568
### `--force-node-api-uncaught-exceptions-policy`
15681569

@@ -2257,9 +2258,11 @@ usually only useful for developers debugging Node.js itself.
22572258
added: v6.9.0
22582259
-->
22592260

2260-
Load an OpenSSL configuration file on startup. Among other uses, this can be
2261-
used to enable FIPS-compliant crypto if Node.js is built
2262-
against FIPS-enabled OpenSSL.
2261+
Load an OpenSSL configuration file on startup. The file can activate an
2262+
OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
2263+
[FIPS mode][].
2264+
2265+
This option takes precedence over the `OPENSSL_CONF` environment variable.
22632266

22642267
### `--openssl-legacy-provider`
22652268

@@ -4234,9 +4237,8 @@ environment variable is arbitrary.
42344237
added: v6.11.0
42354238
-->
42364239

4237-
Load an OpenSSL configuration file on startup. Among other uses, this can be
4238-
used to enable FIPS-compliant crypto if Node.js is built with
4239-
`./configure --openssl-fips`.
4240+
Load an OpenSSL configuration file on startup. The file can be used as part of
4241+
a [FIPS mode][] configuration.
42404242

42414243
If the [`--openssl-config`][] command-line option is used, the environment
42424244
variable is ignored.
@@ -4443,6 +4445,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44434445
[ECMAScript module]: esm.md#modules-ecmascript-modules
44444446
[EventSource Web API]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
44454447
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
4448+
[FIPS mode]: crypto.md#fips-mode
44464449
[File System Permissions]: permissions.md#file-system-permissions
44474450
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
44484451
[Module resolution and loading]: packages.md#module-resolution-and-loading
@@ -4472,6 +4475,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44724475
[`--cpu-prof-dir`]: #--cpu-prof-dir
44734476
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
44744477
[`--disable-sigusr1`]: #--disable-sigusr1
4478+
[`--enable-fips`]: #--enable-fips
44754479
[`--env-file-if-exists`]: #--env-file-if-existsfile
44764480
[`--env-file`]: #--env-filefile
44774481
[`--experimental-sea-config`]: single-executable-applications.md#1-generating-single-executable-preparation-blobs

β€Ždoc/api/crypto.mdβ€Ž

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302

43034303
> Stability: 0 - Deprecated
43044304
4305-
Property for checking and controlling whether a FIPS compliant crypto provider
4306-
is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308-
This property is deprecated. Please use `crypto.setFips()` and
4309-
`crypto.getFips()` instead.
4305+
Deprecated property for checking and controlling [FIPS mode][]. Use
4306+
[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307

43114308
### `crypto.generateKey(type, options, callback)`
43124309

@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894
added: v10.0.0
48984895
-->
48994896

4900-
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901-
currently in use, `0` otherwise. A future semver-major release may change
4902-
the return type of this API to a {boolean}.
4897+
* Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+
semver-major release may change the return type of this API to a {boolean}.
4899+
4900+
With OpenSSL 3, this reports whether the default property query includes
4901+
`fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+
It can return `1` even when a requested cryptographic implementation cannot be
4903+
fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+
mode][].
49034905

49044906
### `crypto.getHashes()`
49054907

@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173
added: v10.0.0
61726174
-->
61736175

6174-
*`bool` {boolean} `true` to enable FIPS mode.
6176+
*`bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+
Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+
the default property query. It does not install, load, initialize, or validate
6180+
a FIPS provider. For a usable FIPS configuration, install the provider and
6181+
configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+
mode][].
6183+
6184+
If no loaded provider supplies a requested cryptographic implementation
6185+
matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+
return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+
operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+
not require a new fetch, including those using previously fetched
6189+
implementations or initialized operation contexts, may still succeed. Call this
6190+
method during application initialization, before application code uses other
6191+
OpenSSL-backed APIs.
6192+
6193+
This method only affects subsequent algorithm fetches. Node.js initializes some
6194+
OpenSSL state before application code runs. When the property query must be
6195+
active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+
configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+
flags additionally require a configured provider named `fips` to initialize and
6198+
pass its self-test; Node.js fails to start otherwise.
61756199

6176-
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177-
Throws an error if FIPS mode is not available.
6200+
Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+
disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+
enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203

61796204
### `crypto.sign(algorithm, data, key[, callback])`
61806205

@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634

66106635
### FIPS mode
66116636

6612-
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613-
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614-
installed by following the instructions in [OpenSSL's FIPS README file][].
6637+
Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+
is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+
provider and only applies when it is deployed according to its security policy.
6640+
Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+
follow the vendor's documentation for those builds.
66156642

6616-
For FIPS support in Node.js you will need:
6643+
With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+
With OpenSSL 3, FIPS support uses the provider model described in the
6646+
[OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647

66186648
* A correctly installed OpenSSL 3 FIPS provider.
66196649
* An OpenSSL 3 [FIPS module configuration file][].
6620-
* An OpenSSL 3 configuration file that references the FIPS module
6621-
configuration file.
6650+
* The FIPS provider to be loaded into the OpenSSL library context used by
6651+
Node.js, normally by activating it in an OpenSSL configuration file when
6652+
Node.js starts.
6653+
* The default property query to include `fips=yes` when cryptographic
6654+
implementations are fetched. This can be set from process startup by the
6655+
OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+
subsequent fetches by `crypto.setFips(true)`.
66226657

6623-
Node.js will need to be configured with an OpenSSL configuration file that
6624-
points to the FIPS provider. An example configuration file looks like this:
6658+
An example OpenSSL 3 configuration file looks like this:
66256659

66266660
```text
66276661
nodejs_conf = nodejs_init
6662+
config_diagnostics = 1
66286663
66296664
.include /<absolute path>/fipsmodule.cnf
66306665
66316666
[nodejs_init]
66326667
providers = provider_sect
6668+
alg_section = algorithm_sect
66336669
66346670
[provider_sect]
6635-
default = default_sect
66366671
# The fips section name should match the section name inside the
66376672
# included fipsmodule.cnf.
66386673
fips = fips_sect
6674+
base = base_sect
66396675
6640-
[default_sect]
6676+
[base_sect]
66416677
activate = 1
6642-
```
6643-
6644-
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645-
FIPS provider installation step:
66466678
6647-
```bash
6648-
openssl fipsinstall
6679+
[algorithm_sect]
6680+
default_properties = fips=yes
66496681
```
66506682

6651-
Set the `OPENSSL_CONF` environment variable to point to
6652-
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653-
provider dynamic library. e.g.
6683+
The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+
and contains module integrity and self-test information. The exact command and
6685+
arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+
[OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+
The example activates the provider and enables the `fips=yes` property query
6689+
when Node.js starts. To activate the provider at startup but enable the property
6690+
query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+
the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+
startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+
should be called before application code uses other OpenSSL-backed APIs. It is
6694+
not equivalent to enabling the property query from process startup because
6695+
Node.js initializes some OpenSSL state before application code runs. Use the
6696+
example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+
query must be active from process startup.
6698+
6699+
`config_diagnostics` causes configuration errors to prevent startup instead of
6700+
being ignored. The `base` provider supplies non-cryptographic supporting
6701+
algorithms, such as encoders and decoders, that are commonly needed alongside
6702+
the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+
algorithm selection to implementations that match `fips=yes`.
6704+
6705+
Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+
provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+
For example:
66546708

66556709
```bash
66566710
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712
```
66596713

6660-
FIPS mode can then be enabled in Node.js either by:
6661-
6662-
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663-
* Programmatically calling `crypto.setFips(true)`.
6664-
6665-
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666-
file. e.g.
6667-
6668-
```text
6669-
nodejs_conf = nodejs_init
6670-
6671-
.include /<absolute path>/fipsmodule.cnf
6672-
6673-
[nodejs_init]
6674-
providers = provider_sect
6675-
alg_section = algorithm_sect
6676-
6677-
[provider_sect]
6678-
default = default_sect
6679-
# The fips section name should match the section name inside the
6680-
# included fipsmodule.cnf.
6681-
fips = fips_sect
6682-
6683-
[default_sect]
6684-
activate = 1
6685-
6686-
[algorithm_sect]
6687-
default_properties = fips=yes
6688-
```
6714+
The [`--openssl-config`][] command-line option selects the configuration file and
6715+
takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+
configuration file is used.
6717+
6718+
By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+
`openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+
or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+
default section name.
6722+
6723+
On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+
startup. The following controls are also available:
6725+
6726+
*[`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+
additionally require the configured provider named `fips` to initialize and
6728+
pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+
prevents FIPS mode from being disabled from script code.
6730+
*[`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+
does not install, load, initialize, or validate a provider. Implementations
6732+
fetched before the call are not changed.
6733+
*[`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+
return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+
With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+
require a FIPS-capable OpenSSL build.
6738+
6739+
Only algorithms available under the active FIPS settings can be used. With
6740+
OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+
implementation matching `fips=yes`, fetching it fails, typically with
6742+
`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+
Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+
active FIPS settings.
6745+
6746+
OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+
of `libcrypto` in one process. This can affect native addons that load another
6748+
copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+
of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+
limitations][].
66896751

66906752
## Crypto constants
66916753

@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031
[Caveats]: #support-for-weak-or-compromised-algorithms
69707032
[Crypto constants]: #crypto-constants
6971-
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972-
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
7033+
[FIPS mode]: #fips-mode
7034+
[FIPS module configuration file]: https://docs.openssl.org/3.0/man5/fips_config/
69737035
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036
[JWK]: https://tools.ietf.org/html/rfc7517
69757037
[Key usages]: webcrypto.md#cryptokeyusages
69767038
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979-
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+
[OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+
[OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+
[OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045
[Permission Model]: permissions.md#permission-model
69827046
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057
[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058
[Web Crypto API documentation]: webcrypto.md
69957059
[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+
[`--enable-fips`]: cli.md#--enable-fips
7061+
[`--force-fips`]: cli.md#--force-fips
7062+
[`--openssl-config`]: cli.md#--openssl-configfile
7063+
[`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065
[`Buffer`]: buffer.md
69987066
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087
[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088
[`crypto.getCurves()`]: #cryptogetcurves
70217089
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+
[`crypto.getFips()`]: #cryptogetfips
70227091
[`crypto.getHashes()`]: #cryptogethashes
70237092
[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+
[`crypto.setFips()`]: #cryptosetfipsbool
70307100
[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101
[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit 9a256b0

Browse files
panvaaduh95
authored andcommitted
doc: clarify OpenSSL FIPS configuration
Distinguish OpenSSL 3 provider setup from FIPS/property-query state, document configuration precedence and provider limitations, and retain the OpenSSL 1.1 and runtime control guidance. Regenerate the CLI manpage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64982 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 28f662b commit 9a256b0

4 files changed

Lines changed: 164 additions & 87 deletions

File tree

β€ŽBUILDING.mdβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
10321032
### Configure OpenSSL appname
10331033

10341034
Node.js can use an OpenSSL configuration file by specifying the environment
1035-
variable `OPENSSL_CONF`, or using the command line option `--openssl-conf`, and
1036-
if none of those are specified will default to reading the default OpenSSL
1037-
configuration file `openssl.cnf`. Node.js will only read a section that is by
1038-
default named `nodejs_conf`, but this name can be overridden using the following
1039-
configure option:
1035+
variable `OPENSSL_CONF`, or using the command line option `--openssl-config`,
1036+
which takes precedence. If neither is specified, Node.js defaults to reading the
1037+
default OpenSSL configuration file `openssl.cnf`. Node.js will only read a
1038+
section that is by default named `nodejs_conf`, but this name can be overridden
1039+
using the following configure option:
10401040

10411041
```bash
10421042
./configure --openssl-conf-name=<some_conf_name>
@@ -1048,6 +1048,8 @@ Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
10481048
[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
10491049
It is not necessary to rebuild Node.js to enable support for FIPS.
10501050

1051+
When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
1052+
10511053
See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
10521054
enable FIPS support in Node.js.
10531055

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,9 @@ priority than `--dns-result-order`.
881881
added: v6.0.0
882882
-->
883883

884-
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
885-
against FIPS-compatible OpenSSL.)
884+
Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
885+
`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
886+
Node.js must be built against a FIPS-capable OpenSSL.
886887

887888
### `--enable-source-maps`
888889

@@ -1561,8 +1562,8 @@ Disable loading native addons that are not [context-aware][].
15611562
added: v6.0.0
15621563
-->
15631564

1564-
Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.)
1565-
(Same requirements as `--enable-fips`.)
1565+
Enable [FIPS mode][] at startup and prevent it from being disabled from script
1566+
code. The same OpenSSL requirements as [`--enable-fips`][] apply.
15661567

15671568
### `--force-node-api-uncaught-exceptions-policy`
15681569

@@ -2257,9 +2258,11 @@ usually only useful for developers debugging Node.js itself.
22572258
added: v6.9.0
22582259
-->
22592260

2260-
Load an OpenSSL configuration file on startup. Among other uses, this can be
2261-
used to enable FIPS-compliant crypto if Node.js is built
2262-
against FIPS-enabled OpenSSL.
2261+
Load an OpenSSL configuration file on startup. The file can activate an
2262+
OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
2263+
[FIPS mode][].
2264+
2265+
This option takes precedence over the `OPENSSL_CONF` environment variable.
22632266

22642267
### `--openssl-legacy-provider`
22652268

@@ -4234,9 +4237,8 @@ environment variable is arbitrary.
42344237
added: v6.11.0
42354238
-->
42364239

4237-
Load an OpenSSL configuration file on startup. Among other uses, this can be
4238-
used to enable FIPS-compliant crypto if Node.js is built with
4239-
`./configure --openssl-fips`.
4240+
Load an OpenSSL configuration file on startup. The file can be used as part of
4241+
a [FIPS mode][] configuration.
42404242

42414243
If the [`--openssl-config`][] command-line option is used, the environment
42424244
variable is ignored.
@@ -4443,6 +4445,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44434445
[ECMAScript module]: esm.md#modules-ecmascript-modules
44444446
[EventSource Web API]: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
44454447
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
4448+
[FIPS mode]: crypto.md#fips-mode
44464449
[File System Permissions]: permissions.md#file-system-permissions
44474450
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
44484451
[Module resolution and loading]: packages.md#module-resolution-and-loading
@@ -4472,6 +4475,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44724475
[`--cpu-prof-dir`]: #--cpu-prof-dir
44734476
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
44744477
[`--disable-sigusr1`]: #--disable-sigusr1
4478+
[`--enable-fips`]: #--enable-fips
44754479
[`--env-file-if-exists`]: #--env-file-if-existsfile
44764480
[`--env-file`]: #--env-filefile
44774481
[`--experimental-sea-config`]: single-executable-applications.md#1-generating-single-executable-preparation-blobs

β€Ždoc/api/crypto.mdβ€Ž

Lines changed: 132 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302

43034303
> Stability: 0 - Deprecated
43044304
4305-
Property for checking and controlling whether a FIPS compliant crypto provider
4306-
is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308-
This property is deprecated. Please use `crypto.setFips()` and
4309-
`crypto.getFips()` instead.
4305+
Deprecated property for checking and controlling [FIPS mode][]. Use
4306+
[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307

43114308
### `crypto.generateKey(type, options, callback)`
43124309

@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894
added: v10.0.0
48984895
-->
48994896

4900-
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901-
currently in use, `0` otherwise. A future semver-major release may change
4902-
the return type of this API to a {boolean}.
4897+
* Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+
semver-major release may change the return type of this API to a {boolean}.
4899+
4900+
With OpenSSL 3, this reports whether the default property query includes
4901+
`fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+
It can return `1` even when a requested cryptographic implementation cannot be
4903+
fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+
mode][].
49034905

49044906
### `crypto.getHashes()`
49054907

@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173
added: v10.0.0
61726174
-->
61736175

6174-
*`bool` {boolean} `true` to enable FIPS mode.
6176+
*`bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+
Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+
the default property query. It does not install, load, initialize, or validate
6180+
a FIPS provider. For a usable FIPS configuration, install the provider and
6181+
configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+
mode][].
6183+
6184+
If no loaded provider supplies a requested cryptographic implementation
6185+
matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+
return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+
operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+
not require a new fetch, including those using previously fetched
6189+
implementations or initialized operation contexts, may still succeed. Call this
6190+
method during application initialization, before application code uses other
6191+
OpenSSL-backed APIs.
6192+
6193+
This method only affects subsequent algorithm fetches. Node.js initializes some
6194+
OpenSSL state before application code runs. When the property query must be
6195+
active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+
configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+
flags additionally require a configured provider named `fips` to initialize and
6198+
pass its self-test; Node.js fails to start otherwise.
61756199

6176-
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177-
Throws an error if FIPS mode is not available.
6200+
Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+
disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+
enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203

61796204
### `crypto.sign(algorithm, data, key[, callback])`
61806205

@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634

66106635
### FIPS mode
66116636

6612-
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613-
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614-
installed by following the instructions in [OpenSSL's FIPS README file][].
6637+
Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+
is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+
provider and only applies when it is deployed according to its security policy.
6640+
Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+
follow the vendor's documentation for those builds.
66156642

6616-
For FIPS support in Node.js you will need:
6643+
With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+
With OpenSSL 3, FIPS support uses the provider model described in the
6646+
[OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647

66186648
* A correctly installed OpenSSL 3 FIPS provider.
66196649
* An OpenSSL 3 [FIPS module configuration file][].
6620-
* An OpenSSL 3 configuration file that references the FIPS module
6621-
configuration file.
6650+
* The FIPS provider to be loaded into the OpenSSL library context used by
6651+
Node.js, normally by activating it in an OpenSSL configuration file when
6652+
Node.js starts.
6653+
* The default property query to include `fips=yes` when cryptographic
6654+
implementations are fetched. This can be set from process startup by the
6655+
OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+
subsequent fetches by `crypto.setFips(true)`.
66226657

6623-
Node.js will need to be configured with an OpenSSL configuration file that
6624-
points to the FIPS provider. An example configuration file looks like this:
6658+
An example OpenSSL 3 configuration file looks like this:
66256659

66266660
```text
66276661
nodejs_conf = nodejs_init
6662+
config_diagnostics = 1
66286663
66296664
.include /<absolute path>/fipsmodule.cnf
66306665
66316666
[nodejs_init]
66326667
providers = provider_sect
6668+
alg_section = algorithm_sect
66336669
66346670
[provider_sect]
6635-
default = default_sect
66366671
# The fips section name should match the section name inside the
66376672
# included fipsmodule.cnf.
66386673
fips = fips_sect
6674+
base = base_sect
66396675
6640-
[default_sect]
6676+
[base_sect]
66416677
activate = 1
6642-
```
6643-
6644-
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645-
FIPS provider installation step:
66466678
6647-
```bash
6648-
openssl fipsinstall
6679+
[algorithm_sect]
6680+
default_properties = fips=yes
66496681
```
66506682

6651-
Set the `OPENSSL_CONF` environment variable to point to
6652-
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653-
provider dynamic library. e.g.
6683+
The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+
and contains module integrity and self-test information. The exact command and
6685+
arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+
[OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+
The example activates the provider and enables the `fips=yes` property query
6689+
when Node.js starts. To activate the provider at startup but enable the property
6690+
query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+
the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+
startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+
should be called before application code uses other OpenSSL-backed APIs. It is
6694+
not equivalent to enabling the property query from process startup because
6695+
Node.js initializes some OpenSSL state before application code runs. Use the
6696+
example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+
query must be active from process startup.
6698+
6699+
`config_diagnostics` causes configuration errors to prevent startup instead of
6700+
being ignored. The `base` provider supplies non-cryptographic supporting
6701+
algorithms, such as encoders and decoders, that are commonly needed alongside
6702+
the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+
algorithm selection to implementations that match `fips=yes`.
6704+
6705+
Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+
provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+
For example:
66546708

66556709
```bash
66566710
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712
```
66596713

6660-
FIPS mode can then be enabled in Node.js either by:
6661-
6662-
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663-
* Programmatically calling `crypto.setFips(true)`.
6664-
6665-
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666-
file. e.g.
6667-
6668-
```text
6669-
nodejs_conf = nodejs_init
6670-
6671-
.include /<absolute path>/fipsmodule.cnf
6672-
6673-
[nodejs_init]
6674-
providers = provider_sect
6675-
alg_section = algorithm_sect
6676-
6677-
[provider_sect]
6678-
default = default_sect
6679-
# The fips section name should match the section name inside the
6680-
# included fipsmodule.cnf.
6681-
fips = fips_sect
6682-
6683-
[default_sect]
6684-
activate = 1
6685-
6686-
[algorithm_sect]
6687-
default_properties = fips=yes
6688-
```
6714+
The [`--openssl-config`][] command-line option selects the configuration file and
6715+
takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+
configuration file is used.
6717+
6718+
By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+
`openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+
or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+
default section name.
6722+
6723+
On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+
startup. The following controls are also available:
6725+
6726+
*[`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+
additionally require the configured provider named `fips` to initialize and
6728+
pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+
prevents FIPS mode from being disabled from script code.
6730+
*[`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+
does not install, load, initialize, or validate a provider. Implementations
6732+
fetched before the call are not changed.
6733+
*[`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+
return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+
With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+
require a FIPS-capable OpenSSL build.
6738+
6739+
Only algorithms available under the active FIPS settings can be used. With
6740+
OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+
implementation matching `fips=yes`, fetching it fails, typically with
6742+
`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+
Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+
active FIPS settings.
6745+
6746+
OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+
of `libcrypto` in one process. This can affect native addons that load another
6748+
copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+
of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+
limitations][].
66896751

66906752
## Crypto constants
66916753

@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031
[Caveats]: #support-for-weak-or-compromised-algorithms
69707032
[Crypto constants]: #crypto-constants
6971-
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972-
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
7033+
[FIPS mode]: #fips-mode
7034+
[FIPS module configuration file]: https://docs.openssl.org/3.0/man5/fips_config/
69737035
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036
[JWK]: https://tools.ietf.org/html/rfc7517
69757037
[Key usages]: webcrypto.md#cryptokeyusages
69767038
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979-
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+
[OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+
[OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+
[OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045
[Permission Model]: permissions.md#permission-model
69827046
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057
[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058
[Web Crypto API documentation]: webcrypto.md
69957059
[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+
[`--enable-fips`]: cli.md#--enable-fips
7061+
[`--force-fips`]: cli.md#--force-fips
7062+
[`--openssl-config`]: cli.md#--openssl-configfile
7063+
[`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065
[`Buffer`]: buffer.md
69987066
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087
[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088
[`crypto.getCurves()`]: #cryptogetcurves
70217089
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+
[`crypto.getFips()`]: #cryptogetfips
70227091
[`crypto.getHashes()`]: #cryptogethashes
70237092
[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+
[`crypto.setFips()`]: #cryptosetfipsbool
70307100
[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101
[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray

0 commit comments

Comments
Β (0)