Skip to content

Commit 2b63396

Browse files
author
Shigeki Ohtsu
committed
deps: add -no_rand_screen to openssl s_client
In openssl s_client on Windows, RAND_screen() is invoked to initialize random state but it takes several seconds in each connection. This added -no_rand_screen to openssl s_client on Windows to skip RAND_screen() and gets a better performance in the unit test of test-tls-server-verify. Do not enable this except to use in the unit test. (cherry picked from commit 9f0f7c38e6df975dd39735d0e9ef968076369c74) Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: nodejs/node-v0.x-archive#25368
1 parent f21705d commit 2b63396

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

deps/openssl/openssl/apps/app_rand.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
124124
char buffer[200];
125125

126126
#ifdef OPENSSL_SYS_WINDOWS
127-
BIO_printf(bio_e, "Loading 'screen' into random state -");
128-
BIO_flush(bio_e);
129-
RAND_screen();
130-
BIO_printf(bio_e, " done\n");
127+
/*
128+
* allocate 2 to dont_warn not to use RAND_screen() via
129+
* -no_rand_screen option in s_client
130+
*/
131+
if (dont_warn != 2) {
132+
BIO_printf(bio_e, "Loading 'screen' into random state -");
133+
BIO_flush(bio_e);
134+
RAND_screen();
135+
BIO_printf(bio_e, " done\n");
136+
}
131137
#endif
132138

133139
if (file == NULL)

deps/openssl/openssl/apps/s_client.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ static int ocsp_resp_cb(SSL *s, void *arg);
233233
static BIO *bio_c_out = NULL;
234234
static int c_quiet = 0;
235235
static int c_ign_eof = 0;
236+
static int c_no_rand_screen = 0;
236237

237238
#ifndef OPENSSL_NO_PSK
238239
/* Default PSK identity and key */
@@ -435,6 +436,10 @@ static void sc_usage(void)
435436
" -keymatexport label - Export keying material using label\n");
436437
BIO_printf(bio_err,
437438
" -keymatexportlen len - Export len bytes of keying material (default 20)\n");
439+
#ifdef OPENSSL_SYS_WINDOWS
440+
BIO_printf(bio_err,
441+
" -no_rand_screen - Do not use RAND_screen() to initialize random state\n");
442+
#endif
438443
}
439444

440445
#ifndef OPENSSL_NO_TLSEXT
@@ -1011,6 +1016,10 @@ int MAIN(int argc, char **argv)
10111016
keymatexportlen = atoi(*(++argv));
10121017
if (keymatexportlen == 0)
10131018
goto bad;
1019+
#ifdef OPENSSL_SYS_WINDOWS
1020+
} else if (strcmp(*argv, "-no_rand_screen") == 0) {
1021+
c_no_rand_screen = 1;
1022+
#endif
10141023
} else {
10151024
BIO_printf(bio_err, "unknown option %s\n", *argv);
10161025
badop = 1;
@@ -1094,7 +1103,7 @@ int MAIN(int argc, char **argv)
10941103
}
10951104
}
10961105

1097-
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
1106+
if (!app_RAND_load_file(NULL, bio_err, ++c_no_rand_screen) && inrand == NULL
10981107
&& !RAND_status()) {
10991108
BIO_printf(bio_err,
11001109
"warning, not much extra random data, consider using the -rand option\n");

0 commit comments

Comments
 (0)