-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build,src,test,doc: enable FIPS for OpenSSL 3.0 #38633
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d664951
build,src,test,doc: enable FIPS for OpenSSL 3.0
danbev 3695a5c
squash! build,src,test,doc: enable FIPS for OpenSSL 3.0
danbev 21b475c
squash! build,src,test,doc: enable FIPS for OpenSSL 3.0
danbev ccb63c0
squash! build,src,test,doc: enable FIPS for OpenSSL 3.0
danbev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -759,7 +759,135 @@ as `deps/icu` (You'll have: `deps/icu/source/...`) | |
|
||
## Building Node.js with FIPS-compliant OpenSSL | ||
|
||
The current version of Node.js does not support FIPS. | ||
The current version of Node.js does not support FIPS when statically linking | ||
(the default) with OpenSSL 1.1.1 but for dynamically linking it is possible | ||
to enable FIPS using the configuration flag `--openssl-is-fips`. | ||
|
||
### Configuring and building quictls/openssl for FIPS | ||
|
||
For quictls/openssl 3.0 it is possible to enable FIPS when dynamically linking. | ||
Node.js currently uses openssl-3.0.0+quic which can be configured as | ||
follows: | ||
```console | ||
$ git clone [email protected]:quictls/openssl.git | ||
$ cd openssl | ||
$ ./config --prefix=/path/to/install/dir/ shared enable-fips linux-x86_64 | ||
``` | ||
This can be compiled and installed using the following commands: | ||
```console | ||
$ make -j8 | ||
$ make install_ssldirs | ||
$ make install_fips | ||
``` | ||
|
||
After the FIPS module and configuration file have been installed by the above | ||
instructions we also need to update `/path/to/install/dir/ssl/openssl.cnf` to | ||
use the generated FIPS configuration file (`fipsmodule.cnf`): | ||
```text | ||
.include fipsmodule.cnf | ||
|
||
# List of providers to load | ||
[provider_sect] | ||
default = default_sect | ||
# The fips section name should match the section name inside the | ||
# included /path/to/install/dir/ssl/fipsmodule.cnf. | ||
fips = fips_sect | ||
|
||
[default_sect] | ||
activate = 1 | ||
``` | ||
|
||
In the above case OpenSSL is not installed in the default location so two | ||
environment variables need to be set, `OPENSSL_CONF`, and `OPENSSL_MODULES` | ||
which should point to the OpenSSL configuration file and the directory where | ||
OpenSSL modules are located: | ||
```console | ||
$ export OPENSSL_CONF=/path/to/install/dir/ssl/openssl.cnf | ||
$ export OPENSSL_MODULES=/path/to/install/dir/lib/ossl-modules | ||
``` | ||
|
||
Node.js can then be configured to enable FIPS: | ||
```console | ||
$ ./configure --shared-openssl --shared-openssl-libpath=/path/to/install/dir/lib --shared-openssl-includes=/path/to/install/dir/include --shared-openssl-libname=crypto,ssl --openssl-is-fips | ||
$ export LD_LIBRARY_PATH=/path/to/install/dir/lib | ||
$ make -j8 | ||
``` | ||
|
||
Verify the produced executable: | ||
```console | ||
$ ldd ./node | ||
linux-vdso.so.1 (0x00007ffd7917b000) | ||
libcrypto.so.81.3 => /path/to/install/dir/lib/libcrypto.so.81.3 (0x00007fd911321000) | ||
libssl.so.81.3 => /path/to/install/dir/lib/libssl.so.81.3 (0x00007fd91125e000) | ||
libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007fd911232000) | ||
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fd911039000) | ||
libm.so.6 => /usr/lib64/libm.so.6 (0x00007fd910ef3000) | ||
libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007fd910ed9000) | ||
libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007fd910eb5000) | ||
libc.so.6 => /usr/lib64/libc.so.6 (0x00007fd910cec000) | ||
/lib64/ld-linux-x86-64.so.2 (0x00007fd9117f2000) | ||
``` | ||
If the `ldd` command says that `libcrypto` cannot be found one needs to set | ||
`LD_LIBRARY_PATH` to point to the directory used above for | ||
`--shared-openssl-libpath` (see previous step). | ||
|
||
Verify the OpenSSL version: | ||
```console | ||
$ ./node -p process.versions.openssl | ||
3.0.0-alpha16+quic | ||
``` | ||
|
||
Verify that FIPS is available: | ||
```console | ||
$ ./node -p 'process.config.variables.openssl_is_fips' | ||
true | ||
$ ./node --enable-fips -p 'crypto.getFips()' | ||
1 | ||
``` | ||
|
||
FIPS support can then be enable via the OpenSSL configuration file or | ||
using `--enable-fips` or `--force-fips` command line options to the Node.js | ||
executable. See sections | ||
[Enabling FIPS using Node.js options](#enabling-fips-using-node.js-options) and | ||
[Enabling FIPS using OpenSSL config](#enabling-fips-using-openssl-config) below. | ||
|
||
### Enabling FIPS using Node.js options | ||
This is done using one of the Node.js options `--enable-fips` or | ||
`--force-fips`, for example: | ||
```console | ||
$ node --enable-fips -p 'crypto.getFips()' | ||
``` | ||
|
||
### Enabling FIPS using OpenSSL config | ||
This example show that using OpenSSL's configuration file, FIPS can be enabled | ||
without specifying the `--enable-fips` or `--force-fips` options by setting | ||
`default_properties = fips=yes` in the FIPS configuration file. See | ||
[link](https://github.com/openssl/openssl/blob/master/README-FIPS.md#loading-the-fips-module-at-the-same-time-as-other-providers) | ||
for details. | ||
|
||
For this to work the OpenSSL configuration file (default openssl.cnf) needs to | ||
be updated. The following shows an example: | ||
```console | ||
openssl_conf = openssl_init | ||
|
||
.include /path/to/install/dir/ssl/fipsmodule.cnf | ||
|
||
[openssl_init] | ||
providers = prov | ||
alg_section = algorithm_sect | ||
|
||
[prov] | ||
fips = fips_sect | ||
default = default_sect | ||
|
||
[default_sect] | ||
activate = 1 | ||
|
||
[algorithm_sect] | ||
default_properties = fips=yes | ||
``` | ||
After this change Node.js can be run without the `--enable-fips` or `--force-fips` | ||
options. | ||
|
||
## Building Node.js with external core modules | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also run
process.report.getReport()
in Node.js and look at thesharedObjects
section to see loaded libraries.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a note about using it. I think it might be useful to keep the
ldd
command just as a way to make sure the libraries can be found or node will note be able to run.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for keeping the
ldd
command. I'm pointing out an alternative... we could possibly also use the report in tests in the future as additional verification.