Skip to content

Commit e552b1a

Browse files
mayrbenjamin92BethGriggs
authored andcommitted
doc: improve node.js+fips instructions
Improves the documentation for building Node.js with openssl-3.0.0+quic with enabled FIPS support. Adds missing but necesary steps to the documentation and makes it complete. Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #39390 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
1 parent b1d38dd commit e552b1a

File tree

1 file changed

+79
-30
lines changed

1 file changed

+79
-30
lines changed

BUILDING.md

Lines changed: 79 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -766,23 +766,42 @@ to enable FIPS using the configuration flag `--openssl-is-fips`.
766766
### Configuring and building quictls/openssl for FIPS
767767

768768
For quictls/openssl 3.0 it is possible to enable FIPS when dynamically linking.
769-
Node.js currently uses openssl-3.0.0+quic which can be configured as
770-
follows:
771-
```console
772-
$ git clone git@github.com:quictls/openssl.git
773-
$ cd openssl
774-
$ ./config --prefix=/path/to/install/dir/ shared enable-fips linux-x86_64
769+
If you want to build Node.js using openssl-3.0.0+quic, you can follow these
770+
steps:
771+
772+
**clone OpenSSL source and prepare build**
773+
```bash
774+
git clone git@github.com:quictls/openssl.git
775+
776+
cd openssl
777+
778+
./config \
779+
--prefix=/path/to/install/dir/ \
780+
shared \
781+
enable-fips \
782+
linux-x86_64
775783
```
776-
This can be compiled and installed using the following commands:
784+
785+
The `/path/to/install/dir` is the path in which the `make install` instructions
786+
will publish the OpenSSL libraries and such. We will also use this path
787+
(and sub-paths) later when compiling Node.js.
788+
789+
**compile and install OpenSSL**
777790
```console
778-
$ make -j8
779-
$ make install_ssldirs
780-
$ make install_fips
791+
make -j8
792+
make install
793+
make install_ssldirs
794+
make install_fips
781795
```
782796

783-
After the FIPS module and configuration file have been installed by the above
784-
instructions we also need to update `/path/to/install/dir/ssl/openssl.cnf` to
785-
use the generated FIPS configuration file (`fipsmodule.cnf`):
797+
After the OpenSSL (including FIPS) modules have been compiled and installed
798+
(into the `/path/to/install/dir`) by the above instructions we also need to
799+
update the OpenSSL configuration file located under
800+
`/path/to/install/dir/ssl/openssl.cnf`. Right next to this file, you should
801+
find the `fipsmodule.cnf` file - let's add the following to the end of the
802+
`openssl.cnf` file.
803+
804+
**alter openssl.cnf**
786805
```text
787806
.include fipsmodule.cnf
788807
@@ -797,25 +816,53 @@ fips = fips_sect
797816
activate = 1
798817
```
799818

800-
In the above case OpenSSL is not installed in the default location so two
801-
environment variables need to be set, `OPENSSL_CONF`, and `OPENSSL_MODULES`
802-
which should point to the OpenSSL configuration file and the directory where
803-
OpenSSL modules are located:
819+
You can e.g. accomplish this by running the following command - be sure to
820+
replace `/path/to/install/dir/` with the path you have selected. Please make
821+
sure that you specify an absolute path for the `.include fipsmodule.cnf` line -
822+
using relative paths did not work on my system!
823+
824+
**alter openssl.cnf using a script**
804825
```console
805-
$ export OPENSSL_CONF=/path/to/install/dir/ssl/openssl.cnf
806-
$ export OPENSSL_MODULES=/path/to/install/dir/lib/ossl-modules
826+
cat <<EOT >> /path/to/install/dir/ssl/openssl.cnf
827+
.include /path/to/install/dir/ssl/fipsmodule.cnf
828+
829+
# List of providers to load
830+
[provider_sect]
831+
default = default_sect
832+
# The fips section name should match the section name inside the
833+
# included /path/to/install/dir/ssl/fipsmodule.cnf.
834+
fips = fips_sect
835+
836+
[default_sect]
837+
activate = 1
838+
EOT
807839
```
808840

809-
Node.js can then be configured to enable FIPS:
841+
As you might have picked a non-custom path for your OpenSSL install dir, we
842+
have to export the following two environment variables in order for Node.js to
843+
find our OpenSSL modules we built beforehand:
810844
```console
811-
$ ./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
812-
$ export LD_LIBRARY_PATH=/path/to/install/dir/lib
813-
$ make -j8
845+
export OPENSSL_CONF=/path/to/install/dir/ssl/openssl.cnf
846+
export OPENSSL_MODULES=/path/to/install/dir/lib/ossl-modules
814847
```
815848

816-
Verify the produced executable:
849+
**build Node.js**
817850
```console
818-
$ ldd ./node
851+
./configure \
852+
--shared-openssl \
853+
--shared-openssl-libpath=/path/to/install/dir/lib \
854+
--shared-openssl-includes=/path/to/install/dir/include \
855+
--shared-openssl-libname=crypto,ssl \
856+
--openssl-is-fips
857+
858+
export LD_LIBRARY_PATH=/path/to/install/dir/lib
859+
860+
make -j8
861+
```
862+
863+
**verify the produced executable**
864+
```console
865+
ldd ./node
819866
linux-vdso.so.1 (0x00007ffd7917b000)
820867
libcrypto.so.81.3 => /path/to/install/dir/lib/libcrypto.so.81.3 (0x00007fd911321000)
821868
libssl.so.81.3 => /path/to/install/dir/lib/libssl.so.81.3 (0x00007fd91125e000)
@@ -827,21 +874,23 @@ $ ldd ./node
827874
libc.so.6 => /usr/lib64/libc.so.6 (0x00007fd910cec000)
828875
/lib64/ld-linux-x86-64.so.2 (0x00007fd9117f2000)
829876
```
877+
830878
If the `ldd` command says that `libcrypto` cannot be found one needs to set
831879
`LD_LIBRARY_PATH` to point to the directory used above for
832880
`--shared-openssl-libpath` (see previous step).
833881

834-
Verify the OpenSSL version:
882+
**verify the OpenSSL version**
835883
```console
836-
$ ./node -p process.versions.openssl
884+
./node -p process.versions.openssl
837885
3.0.0-alpha16+quic
838886
```
839887

840-
Verify that FIPS is available:
888+
**verify that FIPS is available**
841889
```console
842-
$ ./node -p 'process.config.variables.openssl_is_fips'
890+
./node -p 'process.config.variables.openssl_is_fips'
843891
true
844-
$ ./node --enable-fips -p 'crypto.getFips()'
892+
893+
./node --enable-fips -p 'crypto.getFips()'
845894
1
846895
```
847896

0 commit comments

Comments
 (0)