1
1
## How to upgrade openssl library in Node.js
2
2
3
- This document describes the procedure to upgrade openssl from 1.0.2a
4
- to 1.0.2c in Node.js.
5
-
3
+ This document describes the procedure to upgrade openssl from 1.0.2e
4
+ to 1.0.2f in Node.js. This procedure might be applied to upgrading
5
+ any versions in 1.0.2.
6
6
7
7
### Build System and Upgrading Overview
8
8
The openssl build system is based on the ` Configure ` perl script in
@@ -31,6 +31,8 @@ The tested platform in CI are also listed.
31
31
32
32
| --dest-os | --dest-cpu | conf | asm | openssl target | CI |
33
33
| ---------- | ----------- | ----- | ----- | ------------------- | --- |
34
+ | aix | ppc | o | x(* 2)| aix-gcc | o |
35
+ | aix | ppc64 | o | x(* 2)| aix64-gcc | o |
34
36
| linux | ia32 | o | o | linux-elf | o |
35
37
| linux | x32 | o | x(* 2)| linux-x32 | x |
36
38
| linux | x64 | o | o | linux-x86_64 | o |
@@ -91,48 +93,197 @@ https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/sha/asm/sha5
91
93
otherwise asm_obsolete are used.
92
94
93
95
The following is the detail instruction steps how to upgrade openssl
94
- version from 1.0.2a to 1.0.2c in node.
96
+ version from 1.0.2e to 1.0.2f in node.
97
+
98
+ * This needs to run Linux
99
+ enviroment.*
95
100
96
101
### 1. Replace openssl source in ` deps/openssl/openssl `
97
102
Remove old openssl sources in ` deps/openssl/openssl ` .
98
103
Get original openssl sources from
99
- https://www.openssl.org/source/openssl-1.0.2c .tar.gz and extract all
104
+ https://www.openssl.org/source/openssl-1.0.2f .tar.gz and extract all
100
105
files into ` deps/openssl/openssl ` .
101
106
102
- ### 2. Apply private patches
103
- There are three kinds of private patches to be applied in openssl-1.0.2c.
104
-
105
- - The two fixes of assembly error on ia32 win32. masm is no longer
106
- supported in openssl. We should move to use nasm or yasm in future
107
- version of node.
108
-
109
- - The fix of openssl-cli built on win. Key press requirement of
110
- openssl-cli in win causes timeout failures of several tests.
107
+ ``` sh
108
+ ohtsu@ubuntu: ~ /github/node$ cd deps/ openssl/
109
+ ohtsu@ubuntu: ~ /github/node/deps/openssl$ rm -rf openssl
110
+ ohtsu@ubuntu: ~ /github/node/deps/openssl$ tar zxf ~ /tmp/openssl-1.0.2f.tar.gz
111
+ ohtsu@ubuntu: ~ /github/node/deps/openssl$ mv openssl-1.0.2f openssl
112
+ ohtsu@ubuntu: ~ /github/node/deps/openssl$ git add --all openssl
113
+ ohtsu@ubuntu: ~ /github/node/deps/openssl$ git commit openssl
114
+ ````
115
+ The commit message can be
111
116
112
- - A new ` -no_rand_screen ` option to openssl s_client. This makes test
113
- time of test-tls-server-verify be much faster.
117
+ > deps: upgrade openssl sources to 1.0.2f
118
+ >
119
+ > This replaces all sources of openssl-1.0.2f.tar.gz into
120
+ > deps/openssl/openssl
114
121
115
- ### 3 . Replace openssl header files in ` deps/openssl/openssl/include/openssl `
122
+ # ## 2 . Replace openssl header files in `deps/openssl/openssl/include/openssl`
116
123
all header files in ` deps/openssl/openssl/include/openssl/* .h` are
117
124
symbolic links in the distributed release tar.gz. They cause issues in
118
125
Windows. They are copied from the real files of symlink origin into
119
126
the include directory. During installation, they also copied into
120
127
` PREFIX/node/include` by tools/install.py.
128
+ ` deps/openssl/openssl/include/openssl/opensslconf.h` and
129
+ ` deps/openssl/openssl/crypto/opensslconf.h` needs to be changed so as
130
+ to refer the platform independent file of ` deps/openssl/config/opensslconf.h`
131
+
132
+ The following shell script (copy_symlink.sh) is my tool for working
133
+ this procedures to invoke it in the ` deps/openssl/openssl/include/openssl/` .
134
+
135
+ ` ` ` sh
136
+ #! /bin/bash
137
+ for var in " $@ "
138
+ do
139
+ if [ -L $var ]; then
140
+ origin=` readlink $var `
141
+ rm $var
142
+ cp $origin $var
143
+ fi
144
+ done
145
+ rm opensslconf.h
146
+ echo ' #include "../../crypto/opensslconf.h"' > opensslconf.h
147
+ rm ../../crypto/opensslconf.h
148
+ echo ' #include "../../config/opensslconf.h"' > ../../crypto/opensslconf.h
149
+ ` ` ` `
150
+
151
+ This step somehow gets troublesome since openssl-1.0.2f because
152
+ symlink headers are removed in tar.gz file and we have to execute
153
+ ./config script to generate them. The config script also generate
154
+ unnecessary platform dependent files in the repository so that we have
155
+ to clean up them after committing header files.
156
+
157
+ ` ` ` sh
158
+ ohtsu@ubuntu:~ /github/node/deps/openssl$ cd openssl/
159
+ ohtsu@ubuntu:~ /github/node/deps/openssl/openssl$ ./config
160
+
161
+ make[1]: Leaving directory ` /home/ohtsu/github/node/deps/openssl/openssl/test'
162
+
163
+ Configured for linux-x86_64.
164
+ ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ cd include/openssl/
165
+ ohtsu@ubuntu:~/github/node/deps/openssl/openssl/include/openssl$ ~/copy_symlink.sh *.h
166
+ ohtsu@ubuntu:~/github/node/deps/openssl/openssl/include/openssl$ cd ../..
167
+ ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ git add include
168
+ ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ git commit include/ crypto/opensslconf.h
169
+ ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ git clean -f
170
+ ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ git checkout Makefile Makefile.bak
171
+ ````
172
+ The commit message can be
173
+
174
+ >deps: copy all openssl header files to include dir
175
+ >
176
+ >All symlink files in `deps/openssl/openssl/include/openssl/`
177
+ >are removed and replaced with real header files to avoid
178
+ >issues on Windows. Two files of opensslconf.h in crypto and
179
+ >include dir are replaced to refer config/opensslconf.h.
180
+
181
+ ### 3. Apply floating patches
182
+ At the time of writing, there are four floating patches to be applied
183
+ to openssl.
184
+
185
+ - Two fixes for assembly errors on ia32 win32.
186
+
187
+ - One fix for openssl-cli built on win. Key press requirement of
188
+ openssl-cli in win causes timeout failures of several tests.
189
+
190
+ - Adding a new `-no_rand_screen` option to openssl s_client. This
191
+ makes test time of test-tls-server-verify be much faster.
192
+
193
+ These fixes can be applied via cherry-pick. The first three will merge without conflict.
194
+ The last commit can be landed using a recursive strategy that prefers newer changes.
195
+
196
+ ```sh
197
+ git cherry-pick c66c3d9fa3f5bab0bdfe363dd947136cf8a3907f
198
+ git cherry-pick 42a8de2ac66b6953cbc731fdb0b128b8019643b2
199
+ git cherry-pick 2eb170874aa5e84e71b62caab7ac9792fd59c10f
200
+ git cherry-pick --strategy=recursive -X theirs 664a659
201
+ ```
202
+
203
+ If you attempted to cherry-pick the last commit you would have the following conflict
204
+
205
+ ```
206
+ # do not do this
207
+ git cherry-pick 664a6596960655e214fef25e74d3285097703e95
208
+ error: could not apply 664a659... deps: add -no_rand_screen to openssl s_client
209
+ hint: after resolving the conflicts, mark the corrected paths
210
+ hint: with ' git add < paths> ' or ' git rm < paths> '
211
+ hint: and commit the result with ' git commit'
212
+ git cherry-pi
213
+ ```
214
+
215
+ the conflict is in `deps/openssl/openssl/apps/app_rand.c` as below.
216
+
217
+ ```sh
218
+ ohtsu@omb:openssl$ git diff
219
+ diff --cc deps/openssl/openssl/apps/app_rand.c
220
+ index 7f40bba,b6fe294..0000000
221
+ --- a/deps/openssl/openssl/apps/app_rand.c
222
+ +++ b/deps/openssl/openssl/apps/app_rand.c
223
+ @@@ -124,7 -124,16 +124,20 @@@ int app_RAND_load_file(const char *file
224
+ char buffer[200];
225
+
226
+ #ifdef OPENSSL_SYS_WINDOWS
227
+ ++<<<<<<< HEAD
228
+ + RAND_screen();
229
+ ++=======
230
+ + /*
231
+ + * allocate 2 to dont_warn not to use RAND_screen() via
232
+ + * -no_rand_screen option in s_client
233
+ + */
234
+ + if (dont_warn != 2) {
235
+ + BIO_printf(bio_e, "Loading ' screen' into random state -");
236
+ + BIO_flush(bio_e);
237
+ + RAND_screen();
238
+ + BIO_printf(bio_e, " done\n");
239
+ + }
240
+ ++>>>>>>> 664a659... deps: add -no_rand_screen to openssl s_client
241
+ #endif
242
+
243
+ if (file == NULL)
244
+ ````
245
+
246
+ We want to opt for the changes from 664a659 instead of the changes present on HEAD.
247
+ `git cherry-pick --strategy=recursive -X theirs` will do just that!
121
248
122
249
### 4. Change `opensslconf.h` so as to fit each platform.
123
- No change.
250
+ opensslconf.h includes defines and macros which are platform
251
+ dependent. Each files can be generated via `deps/openssl/config/Makefile`
252
+ We can regenerate them and commit them if any diffs exist.
253
+
254
+ ```sh
255
+ ohtsu@ubuntu:~/github/node/deps/openssl$ cd config
256
+ ohtsu@ubuntu:~/github/node/deps/openssl/config$ make clean
257
+ find archs -name opensslconf.h -exec rm "{}" \;
258
+ ohtsu@ubuntu:~/github/node/deps/openssl/config$ make
259
+ cd ../openssl; perl ./Configure no-shared no-symlinks aix-gcc > /dev/null
260
+ ohtsu@ubuntu:~/github/node/deps/openssl/config$ git diff
261
+ ohtsu@ubuntu:~/github/node/deps/openssl/config$ git commit .
262
+ ````
263
+ The commit message can be
264
+
265
+ >deps: update openssl config files
266
+ >
267
+ >Regenerate config files for supported platforms with Makefile.
124
268
125
269
### 5. Update openssl.gyp and openssl.gypi
126
- No change.
270
+ This process is needed when source files are removed, renamed and added.
271
+ It seldom happen in the minor bug fix release. Build errors would be
272
+ thrown if it happens. In case of build errors, we need to check source
273
+ files in Makefiles of its platform and change openssl.gyp or
274
+ openssl.gypi according to the changes of source files. Please contact
275
+ @shigeki if it is needed.
127
276
128
277
### 6. ASM files for openssl
129
278
We provide two sets of asm files. One is for the latest assembler
130
- and the other is the older one.
279
+ and the other is the older one. sections 6.1 and 6.2 describe the two
280
+ types of files. Section 6.3 explains the steps to update the files.
281
+ In the case of upgrading 1.0.2f there were no changes to the asm files.
131
282
132
283
### 6.1. asm files for the latest compiler
133
284
This was made in `deps/openssl/asm/Makefile`
134
285
- Updated asm files for each platforms which are required in
135
- openssl-1.0.2c .
286
+ openssl-1.0.2f .
136
287
- Some perl files need CC and ASM envs. Added a check if these envs
137
288
exist. Followed asm files are to be generated with CC=gcc and
138
289
ASM=nasm on Linux. See
@@ -148,8 +299,9 @@ This was made in `deps/openssl/asm/Makefile`
148
299
149
300
With export environments of CC=gcc and ASM=nasm, then type make
150
301
command and check if new asm files are generated.
302
+ If you don' t have nasm please install it such as ` apt-get install nasm` .
151
303
152
- ### 6.2.asm files for the older compiler
304
+ # ## 6.2. asm files for the older compiler
153
305
For older assembler, the version check of CC and ASM should be
154
306
skipped in generating asm file with perl scripts.
155
307
Copy files from ` deps/openssl/asm` into
@@ -158,3 +310,42 @@ into this directories and remove the check of CC and ASM envs.
158
310
159
311
Without environments of CC and ASM, then type make command and check
160
312
if new asm files for older compilers are generated.
313
+
314
+ The following steps includes version check of gcc and nasm.
315
+
316
+ # ## 6.3 steps
317
+
318
+ ` ` ` sh
319
+ ohtsu@ubuntu:~ /github/node/deps/openssl/config$ cd ../asm
320
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm$ gcc --version
321
+ gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
322
+ Copyright (C) 2013 Free Software Foundation, Inc.
323
+ This is free software; see the source for copying conditions. There is NO
324
+ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
325
+
326
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm$ nasm -v
327
+ NASM version 2.10.09 compiled on Dec 29 2013
328
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm$ export CC=gcc
329
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm$ export ASM=nasm
330
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm$ make clean
331
+ find . -iname ' *.asm' -exec rm " {}" \;
332
+ find . -iname ' *.s' -exec rm " {}" \;
333
+ find . -iname ' *.S' -exec rm " {}" \;
334
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm$ make
335
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm$ cd ../asm_obsolete/
336
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm_obsolete$ unset CC
337
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm_obsolete$ unset ASM
338
+ ohtsu@ubuntu:~ /github/node/deps/openssl/asm_obsolete$ make clean
339
+ find . -iname ' *.asm' -exec rm " {}" \;
340
+ find . -iname ' *.s' -exec rm " {}" \;
341
+ find . -iname ' *.S' -exec rm " {}" \;
342
+ ohtsu@ubuntu:~ /github/node/deps/openssl$ git status
343
+ ohtsu@ubuntu:~ /github/node/deps/openssl$ git commit asm asm_obsolete
344
+ ` ` ` `
345
+ The commit message can be
346
+
347
+ > deps: update openssl asm and asm_obsolete files
348
+ >
349
+ > Regenerate asm files with Makefile and CC=gcc and ASM=gcc where
350
+ > gcc-4.8.4. Also asm files in asm_obsolete dir to support old compiler
351
+ > and assembler are regenerated without CC and ASM envs.
0 commit comments