Skip to content

Commit 66da32c

Browse files
committed
deps,test,src,doc,tools: update to OpenSSL 3.0
This pull request updates the OpenSSL version that is statically linked with Node.js from OpenSSl 1.1.1 to quictls OpenSSL 3.0.0+quic. This pull request will replace the OpenSSL version that is currently in the deps directory and when performing a normal build OpenSSL 3.0+quic will be statically linked to the Node.js executable. We will still be able to dynamically link to OpenSSL 1.1.1 and we have a CI job which dynamically links to OpenSSL 1.1.1 which is run for every pull request to make sure that we maintain backward compatibility. PR-URL: nodejs#38512 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 49b7ec9 commit 66da32c

File tree

8,465 files changed

+3975529
-1448370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

8,465 files changed

+3975529
-1448370
lines changed

BUILDING.md

+42-5
Original file line numberDiff line numberDiff line change
@@ -764,11 +764,48 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
764764

765765
## Building Node.js with FIPS-compliant OpenSSL
766766

767-
The current version of Node.js does not support FIPS when statically linking
768-
(the default) with OpenSSL 1.1.1 but for dynamically linking it is possible
769-
to enable FIPS using the configuration flag `--openssl-is-fips`.
767+
The current version of Node.js supports FIPS when statically and
768+
dynamically linking with OpenSSL 3.0.0 by using the configuration flag
769+
`--openssl-is-fips`.
770770

771-
### Configuring and building quictls/openssl for FIPS
771+
### FIPS support when statically linking OpenSSL
772+
773+
FIPS can be supported by specifying the configuration flag `--openssl-is-fips`:
774+
```console
775+
$ ./configure --openssl-is-fips
776+
$ make -j8
777+
```
778+
779+
The above command will build and install the FIPS module into the out directory.
780+
This includes building fips.so, running the `installfips` command that generates
781+
the FIPS configuration file (fipsmodule.cnf), copying and updating openssl.cnf
782+
to include the correct path to fipsmodule.cnf and finally uncomment the fips
783+
section.
784+
785+
We can then run node specifying `--enable-fips`:
786+
```console
787+
$ ./node --enable-fips -p 'crypto.getFips()'
788+
1
789+
```
790+
The above will use the Node.js default locations for OpenSSL 3.0:
791+
```console
792+
$ ./out/Release/openssl-cli version -m -d
793+
OPENSSLDIR: "/nodejs/openssl/out/Release/obj.target/deps/openssl"
794+
MODULESDIR: "/nodejs/openssl/out/Release/obj.target/deps/openssl/lib/openssl-modules"
795+
```
796+
The OpenSSL configuration files will be found in `OPENSSLDIR` directory above:
797+
```console
798+
$ ls -w 1 out/Release/obj.target/deps/openssl/*.cnf
799+
out/Release/obj.target/deps/openssl/fipsmodule.cnf
800+
out/Release/obj.target/deps/openssl/openssl.cnf
801+
```
802+
And the FIPS module will be located in the `MODULESDIR` directory:
803+
```console
804+
$ ls out/Release/obj.target/deps/openssl/lib/openssl-modules/
805+
fips.so
806+
```
807+
808+
### FIPS support when dynamically linking OpenSSL
772809

773810
For quictls/openssl 3.0 it is possible to enable FIPS when dynamically linking.
774811
If you want to build Node.js using openssl-3.0.0+quic, you can follow these
@@ -811,7 +848,7 @@ find the `fipsmodule.cnf` file - let's add the following to the end of the
811848
**alter openssl.cnf**
812849

813850
```text
814-
.include fipsmodule.cnf
851+
.include /absolute/path/to/fipsmodule.cnf
815852
816853
# List of providers to load
817854
[provider_sect]

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ testclean:
188188
.PHONY: distclean
189189
distclean:
190190
$(RM) -r out
191-
$(RM) config.gypi icu_config.gypi config_fips.gypi
191+
$(RM) config.gypi icu_config.gypi
192192
$(RM) config.mk
193193
$(RM) -r $(NODE_EXE) $(NODE_G_EXE)
194194
$(RM) -r node_modules

common.gypi

+1-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
'clang%': 0,
2929
'error_on_warn%': 'false',
3030

31-
'openssl_fips%': '',
31+
'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
3232
'openssl_no_asm%': 0,
3333

3434
# Don't use ICU data file (icudtl.dat) from V8, we use our own.
@@ -98,11 +98,6 @@
9898
'obj_dir%': '<(PRODUCT_DIR)/obj.target',
9999
'v8_base': '<(PRODUCT_DIR)/obj.target/tools/v8_gypfiles/libv8_snapshot.a',
100100
}],
101-
['openssl_fips != ""', {
102-
'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
103-
}, {
104-
'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
105-
}],
106101
['OS=="mac"', {
107102
'clang%': 1,
108103
'obj_dir%': '<(PRODUCT_DIR)/obj.target',

configure.py

+11-25
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@
195195
default=None,
196196
help="Do not build optimized assembly for OpenSSL")
197197

198-
parser.add_argument('--openssl-fips',
199-
action='store',
200-
dest='openssl_fips',
201-
help='Build OpenSSL using FIPS canister .o file in supplied folder')
202-
203198
parser.add_argument('--openssl-is-fips',
204199
action='store_true',
205200
dest='openssl_is_fips',
@@ -1414,8 +1409,7 @@ def configure_openssl(o):
14141409
variables['node_shared_ngtcp2'] = b(options.shared_ngtcp2)
14151410
variables['node_shared_nghttp3'] = b(options.shared_nghttp3)
14161411
variables['openssl_is_fips'] = b(options.openssl_is_fips)
1417-
variables['openssl_fips'] = ''
1418-
variables['openssl_quic'] = b(True)
1412+
variables['node_fipsinstall'] = b(False)
14191413

14201414
if options.openssl_no_asm:
14211415
variables['openssl_no_asm'] = 1
@@ -1427,8 +1421,8 @@ def without_ssl_error(option):
14271421
without_ssl_error('--shared-openssl')
14281422
if options.openssl_no_asm:
14291423
without_ssl_error('--openssl-no-asm')
1430-
if options.openssl_fips:
1431-
without_ssl_error('--openssl-fips')
1424+
if options.openssl_is_fips:
1425+
without_ssl_error('--openssl-is-fips')
14321426
if options.openssl_default_cipher_list:
14331427
without_ssl_error('--openssl-default-cipher-list')
14341428
return
@@ -1468,17 +1462,18 @@ def without_ssl_error(option):
14681462
if options.openssl_no_asm and options.shared_openssl:
14691463
error('--openssl-no-asm is incompatible with --shared-openssl')
14701464

1471-
if options.openssl_fips or options.openssl_fips == '':
1472-
error('FIPS is not supported in this version of Node.js')
1473-
14741465
if options.openssl_is_fips and not options.shared_openssl:
1475-
error('--openssl-is-fips is only available with --shared-openssl')
1476-
1477-
if options.openssl_is_fips:
14781466
o['defines'] += ['OPENSSL_FIPS']
1467+
variables['node_fipsinstall'] = b(True)
14791468

14801469
if options.shared_openssl:
1481-
variables['openssl_quic'] = b(getsharedopensslhasquic.get_has_quic(options.__dict__['shared_openssl_includes']))
1470+
has_quic = getsharedopensslhasquic.get_has_quic(options.__dict__['shared_openssl_includes'])
1471+
else:
1472+
has_quic = getsharedopensslhasquic.get_has_quic('deps/openssl/openssl/include')
1473+
1474+
variables['openssl_quic'] = b(has_quic)
1475+
if has_quic:
1476+
o['defines'] += ['NODE_OPENSSL_HAS_QUIC']
14821477

14831478
configure_library('openssl', o)
14841479

@@ -1927,15 +1922,6 @@ def make_bin_override():
19271922
del output['variables']
19281923
variables['is_debug'] = B(options.debug)
19291924

1930-
# make_global_settings for special FIPS linking
1931-
# should not be used to compile modules in node-gyp
1932-
config_fips = { 'make_global_settings' : [] }
1933-
if 'make_fips_settings' in output:
1934-
config_fips['make_global_settings'] = output['make_fips_settings']
1935-
del output['make_fips_settings']
1936-
write('config_fips.gypi', do_not_edit +
1937-
pprint.pformat(config_fips, indent=2) + '\n')
1938-
19391925
# make_global_settings should be a root level element too
19401926
if 'make_global_settings' in output:
19411927
make_global_settings = output['make_global_settings']

deps/openssl/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
openssl/fuzz/corpora
2+
openssl/makefile.in
3+
openssl/Makefile.in

deps/openssl/README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
This has a new binding scheme in building OpenSSL-1.1.0 library with
2-
Node.js. OpenSSL-1.1.0 uses a new build system with `Perl` for various
1+
This has a new binding scheme in building OpenSSL-3.0.0 library with
2+
Node.js. OpenSSL-3.0.0 uses a new build system with `Perl` for various
33
supported platforms. See `openssl/Configurations/README` and
4-
`openssl/Configurations/README.design` in the OpenSSL source for
4+
`openssl/Configurations/README-design.md` in the OpenSSL source for
55
details.
66

77
In order to build OpenSSL library without `Perl` in the build of Node.js
@@ -13,7 +13,7 @@ and header files ) are pre-generated and stored into the
1313

1414
Makefile has supported platform list and generates and copies
1515
platform dependent files (e.g. asm files) into arch directory with
16-
`generate_gypi.pl`. Platform dependent gypi files also created
16+
`generate_gypi.pl`. Platform dependent gypi files are also created
1717
obtaining build information from `configdata.pm` that is generated
1818
with `Configure` in the OpenSSL build system.
1919

@@ -36,7 +36,8 @@ and header files ) are pre-generated and stored into the
3636
`bn_conf.h`, `dso_conf.h` and `opensslconf.h` are platform dependent
3737
in the OpenSSL sources. They are replaced with `config/*.h.tmpl`
3838
files to include the file in the `../../../config/` and referred to
39-
each arch file that depends on asm and no-asm option.
39+
each arch file that depends on asm and no-asm option. These headers are
40+
generated by the make target `generate_headers`.
4041

4142
### Supported architectures for use of ASM
4243

deps/openssl/config/Makefile

+18-18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ endif
99
PERL = perl
1010

1111
# Supported architecture list
12-
ASM_ARCHS = aix-gcc aix64-gcc BSD-x86 BSD-x86_64 \
12+
ASM_ARCHS = aix-gcc aix64-gcc-as BSD-x86 BSD-x86_64 \
1313
darwin64-x86_64-cc darwin-i386-cc darwin64-arm64-cc linux-aarch64 \
1414
linux-armv4 linux-elf linux-x32 linux-x86_64 linux-ppc \
1515
linux-ppc64 linux-ppc64le linux32-s390x linux64-s390x linux64-mips64\
@@ -25,7 +25,7 @@ CONFIGURE = ./Configure
2525
# no-shared: openssl-cli needs static link
2626
# no-afalgeng: old Linux kernel < 4.0 does not support it
2727
# enable-ssl-trace: cause the optional SSL_trace API to be built
28-
COPTS = no-comp no-shared no-afalgeng enable-ssl-trace
28+
COPTS = no-comp no-shared no-afalgeng enable-ssl-trace enable-fips
2929

3030
# disable platform check in Configure
3131
NO_WARN_ENV = CONFIGURE_CHECKER_WARN=1
@@ -35,41 +35,41 @@ GENERATE = ./generate_gypi.pl
3535
OPSSL_SRC = ../openssl
3636

3737
# Header files generated with Configure
38-
CFG = opensslconf.h
39-
SRC_CFG = $(OPSSL_SRC)/include/openssl/$(CFG)
40-
INT_CFGS = bn_conf.h dso_conf.h
38+
#INT_CFGS = bn_conf.h dso_conf.h
4139
INT_CFG_DIR = $(OPSSL_SRC)/include/crypto
40+
GEN_HEADERS = asn1 asn1t bio cmp cms configuration conf crmf crypto ct err \
41+
ess fipskey lhash ocsp opensslv pkcs12 pkcs7 safestack srp ssl \
42+
ui x509 x509v3 x509_vfy conf
4243

43-
PHONY = all clean replace
44+
CRYPTO_GEN_HEADERS = bn_conf dso_conf
45+
46+
PHONY = all clean replace generate_headers
4447
.PHONY: $(PHONY)
4548

46-
all: $(ASM_ARCHS) $(NO_ASM_ARCHS) replace
49+
#all: $(ASM_ARCHS) $(NO_ASM_ARCHS) generate_headers replace
50+
all: $(ASM_ARCHS) $(NO_ASM_ARCHS) generate_headers
4751

4852
# Configure and generate openssl asm files for each archs
4953
$(ASM_ARCHS):
5054
cd $(OPSSL_SRC); $(NO_WARN_ENV) CC=$(CC) $(PERL) $(CONFIGURE) $(COPTS) $@;
51-
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm $@
55+
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm $@ "${GEN_HEADERS}" "${CRYPTO_GEN_HEADERS}"
5256
# Confgure asm_avx2 and generate upto avx2 support
5357
cd $(OPSSL_SRC); $(NO_WARN_ENV) CC=$(FAKE_GCC) $(PERL) $(CONFIGURE) \
5458
$(COPTS) $@;
55-
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm_avx2 $@
59+
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm_avx2 $@ "${GEN_HEADERS}" "${CRYTO_GEN_HEADERS}"
5660
# Configure no-asm and generate no-asm sources
5761
cd $(OPSSL_SRC); $(NO_WARN_ENV) $(PERL) $(CONFIGURE) $(COPTS) \
5862
no-asm $@;
59-
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) no-asm $@
63+
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) no-asm $@ "${GEN_HEADERS}" "${CRYPTO_GEN_HEADERS}"
6064

6165
$(NO_ASM_ARCHS):
6266
# Configure no-asm and generate no-asm sources
6367
cd $(OPSSL_SRC); $(NO_WARN_ENV) $(PERL) $(CONFIGURE) $(COPTS) \
6468
no-asm $@;
65-
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) no-asm $@
66-
67-
# Replace and copy arch dependent headers
68-
replace:
69-
cp ./$(CFG).tmpl $(SRC_CFG)
70-
@for c in $(INT_CFGS); do \
71-
cp ./$$c.tmpl $(INT_CFG_DIR)/$$c; \
72-
done
69+
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) no-asm $@ "${GEN_HEADERS}" "${CRYPTO_GEN_HEADERS}"
70+
71+
generate_headers:
72+
@$(PERL) -w -I$(OPSSL_SRC) ./generate_headers.pl "${GEN_HEADERS}" "${CRYPTO_GEN_HEADERS}"
7373

7474
clean:
7575
find archs \( -name \*.S -o -name \*.s -o -name \*.asm -o \

0 commit comments

Comments
 (0)