Skip to content

Commit 0720238

Browse files
nikolapajkovskySashan
authored andcommitted
handshake: add freeze option
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
1 parent 4b2a96f commit 0720238

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ handshakes are performed divided evenly among each thread. It take 2 optional
4949
and two required arguments:
5050

5151
```
52-
handshake [-t] [-s] <certsdir> <threadcount>
52+
handshake [-t] [-s] [-f] <certsdir> <threadcount>
5353
-t - produce terse output
54+
-f - freeze default context (available only with openssl >= 4.x.x)
5455
-s - create an ssl_ctx per connection, rather than a single thread-shared ctx
5556
-p - use ossl_lib_ctx per thread
5657
-P - use ossl_lib_ctx pool (can be combined with -s. If sharing is enabled, ssl_ctx

source/handshake.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* https://www.openssl.org/source/license.html
88
*/
99

10+
#include "config.h"
1011
#include <stdlib.h>
1112
#include <stdio.h>
1213
#include <string.h>
@@ -336,6 +337,9 @@ void usage(const char *progname)
336337
printf("-P - use ossl_lib_ctx pool\n");
337338
printf("-l - use ssl ctx pool\n");
338339
printf("-o - set ossl_lib_ctx pool size\n");
340+
#endif
341+
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
342+
printf("-f - freeze default context\n");
339343
#endif
340344
printf("-S [n] - use secure memory\n");
341345
printf("-V - print version information and exit\n");
@@ -353,15 +357,21 @@ int main(int argc, char * const argv[])
353357
int opt;
354358
int p_flag = 0, P_flag = 0, l_flag = 0;
355359
char *endptr = NULL;
356-
357-
while ((opt = getopt(argc, argv,
358-
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
359-
"tspPo:lS:V"
360+
char *getopt_options = "tsS:V";
361+
#if OPENSSL_VERSION_NUMBER >= 0x30000000L && defined(HAVE_OSSL_LIB_CTX_FREEZE)
362+
int freeze = 0;
363+
getopt_options = "tspPo:lS:Vf";
360364
#else
361-
"tsS:V"
365+
getopt_options = "tspPo:lS:V";
362366
#endif
363-
)) != -1) {
367+
368+
while ((opt = getopt(argc, argv, getopt_options)) != -1) {
364369
switch (opt) {
370+
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
371+
case 'f':
372+
freeze = 1;
373+
break;
374+
#endif
365375
case 't':
366376
terse = 1;
367377
break;
@@ -474,6 +484,15 @@ int main(int argc, char * const argv[])
474484

475485
max_time = ossl_time_add(ossl_time_now(), ossl_seconds2time(RUN_TIME));
476486

487+
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
488+
if (freeze) {
489+
if (OSSL_LIB_CTX_freeze(NULL, NULL) == 0) {
490+
fprintf(stderr, "Freezing LIB CTX failed\n");
491+
goto err;
492+
}
493+
}
494+
#endif
495+
477496
switch (test_case) {
478497
case TC_SSL_CTX: {
479498
if (share_ctx == 1) {

0 commit comments

Comments
 (0)