diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/openssl.1 | 9 | ||||
| -rw-r--r-- | src/usr.bin/openssl/s_apps.h | 4 | ||||
| -rw-r--r-- | src/usr.bin/openssl/s_server.c | 19 | ||||
| -rw-r--r-- | src/usr.bin/openssl/s_socket.c | 8 |
4 files changed, 29 insertions, 11 deletions
diff --git a/src/usr.bin/openssl/openssl.1 b/src/usr.bin/openssl/openssl.1 index 84627a84a5..9d9f5ca580 100644 --- a/src/usr.bin/openssl/openssl.1 +++ b/src/usr.bin/openssl/openssl.1 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: openssl.1,v 1.129 2021/03/17 18:08:32 jsing Exp $ | 1 | .\" $OpenBSD: openssl.1,v 1.130 2021/08/29 12:33:15 tb Exp $ |
| 2 | .\" ==================================================================== | 2 | .\" ==================================================================== |
| 3 | .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | 3 | .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. |
| 4 | .\" | 4 | .\" |
| @@ -110,7 +110,7 @@ | |||
| 110 | .\" copied and put under another distribution licence | 110 | .\" copied and put under another distribution licence |
| 111 | .\" [including the GNU Public Licence.] | 111 | .\" [including the GNU Public Licence.] |
| 112 | .\" | 112 | .\" |
| 113 | .Dd $Mdocdate: March 17 2021 $ | 113 | .Dd $Mdocdate: August 29 2021 $ |
| 114 | .Dt OPENSSL 1 | 114 | .Dt OPENSSL 1 |
| 115 | .Os | 115 | .Os |
| 116 | .Sh NAME | 116 | .Sh NAME |
| @@ -4607,6 +4607,7 @@ will be used. | |||
| 4607 | .Op Fl keymatexportlen Ar len | 4607 | .Op Fl keymatexportlen Ar len |
| 4608 | .Op Fl msg | 4608 | .Op Fl msg |
| 4609 | .Op Fl mtu Ar mtu | 4609 | .Op Fl mtu Ar mtu |
| 4610 | .Op Fl naccept Ar num | ||
| 4610 | .Op Fl named_curve Ar arg | 4611 | .Op Fl named_curve Ar arg |
| 4611 | .Op Fl nbio | 4612 | .Op Fl nbio |
| 4612 | .Op Fl nbio_test | 4613 | .Op Fl nbio_test |
| @@ -4807,6 +4808,10 @@ Export len bytes of keying material (default 20). | |||
| 4807 | Show all protocol messages with hex dump. | 4808 | Show all protocol messages with hex dump. |
| 4808 | .It Fl mtu Ar mtu | 4809 | .It Fl mtu Ar mtu |
| 4809 | Set the link layer MTU. | 4810 | Set the link layer MTU. |
| 4811 | .It Fl naccept Ar num | ||
| 4812 | Terminate server after | ||
| 4813 | .Ar num | ||
| 4814 | connections. | ||
| 4810 | .It Fl named_curve Ar arg | 4815 | .It Fl named_curve Ar arg |
| 4811 | Specify the elliptic curve name to use for ephemeral ECDH keys. | 4816 | Specify the elliptic curve name to use for ephemeral ECDH keys. |
| 4812 | This option is deprecated; use | 4817 | This option is deprecated; use |
diff --git a/src/usr.bin/openssl/s_apps.h b/src/usr.bin/openssl/s_apps.h index 9ee0bb7dc1..f535a35c39 100644 --- a/src/usr.bin/openssl/s_apps.h +++ b/src/usr.bin/openssl/s_apps.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s_apps.h,v 1.5 2018/04/25 07:12:33 tb Exp $ */ | 1 | /* $OpenBSD: s_apps.h,v 1.6 2021/08/29 12:33:15 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -120,7 +120,7 @@ extern int verify_return_error; | |||
| 120 | 120 | ||
| 121 | int do_server(int port, int type, int *ret, | 121 | int do_server(int port, int type, int *ret, |
| 122 | int (*cb)(char *hostname, int s, unsigned char *context), | 122 | int (*cb)(char *hostname, int s, unsigned char *context), |
| 123 | unsigned char *context); | 123 | unsigned char *context, int naccept); |
| 124 | #ifdef HEADER_X509_H | 124 | #ifdef HEADER_X509_H |
| 125 | int verify_callback(int ok, X509_STORE_CTX *ctx); | 125 | int verify_callback(int ok, X509_STORE_CTX *ctx); |
| 126 | #endif | 126 | #endif |
diff --git a/src/usr.bin/openssl/s_server.c b/src/usr.bin/openssl/s_server.c index 1bd544324a..abe2ee42ae 100644 --- a/src/usr.bin/openssl/s_server.c +++ b/src/usr.bin/openssl/s_server.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s_server.c,v 1.47 2021/03/17 18:11:01 jsing Exp $ */ | 1 | /* $OpenBSD: s_server.c,v 1.48 2021/08/29 12:33:15 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -267,6 +267,7 @@ static struct { | |||
| 267 | uint16_t min_version; | 267 | uint16_t min_version; |
| 268 | const SSL_METHOD *meth; | 268 | const SSL_METHOD *meth; |
| 269 | int msg; | 269 | int msg; |
| 270 | int naccept; | ||
| 270 | char *named_curve; | 271 | char *named_curve; |
| 271 | int nbio; | 272 | int nbio; |
| 272 | int nbio_test; | 273 | int nbio_test; |
| @@ -741,6 +742,13 @@ static const struct option s_server_options[] = { | |||
| 741 | }, | 742 | }, |
| 742 | #endif | 743 | #endif |
| 743 | { | 744 | { |
| 745 | .name = "naccept", | ||
| 746 | .argname = "num", | ||
| 747 | .desc = "terminate after num connections", | ||
| 748 | .type = OPTION_ARG_INT, | ||
| 749 | .opt.value = &s_server_config.naccept | ||
| 750 | }, | ||
| 751 | { | ||
| 744 | .name = "named_curve", | 752 | .name = "named_curve", |
| 745 | .argname = "arg", | 753 | .argname = "arg", |
| 746 | .type = OPTION_ARG, | 754 | .type = OPTION_ARG, |
| @@ -1045,7 +1053,7 @@ sv_usage(void) | |||
| 1045 | " [-dpass arg] [-dtls] [-dtls1] [-dtls1_2] [-groups list] [-HTTP]\n" | 1053 | " [-dpass arg] [-dtls] [-dtls1] [-dtls1_2] [-groups list] [-HTTP]\n" |
| 1046 | " [-id_prefix arg] [-key keyfile] [-key2 keyfile]\n" | 1054 | " [-id_prefix arg] [-key keyfile] [-key2 keyfile]\n" |
| 1047 | " [-keyform der | pem] [-keymatexport label]\n" | 1055 | " [-keyform der | pem] [-keymatexport label]\n" |
| 1048 | " [-keymatexportlen len] [-msg] [-mtu mtu]\n" | 1056 | " [-keymatexportlen len] [-msg] [-mtu mtu] [-naccept num]\n" |
| 1049 | " [-named_curve arg] [-nbio] [-nbio_test] [-no_cache]\n" | 1057 | " [-named_curve arg] [-nbio] [-nbio_test] [-no_cache]\n" |
| 1050 | " [-no_dhe] [-no_ecdhe] [-no_ticket] [-no_tls1]\n" | 1058 | " [-no_dhe] [-no_ecdhe] [-no_ticket] [-no_tls1]\n" |
| 1051 | " [-no_tls1_1] [-no_tls1_2] [-no_tls1_3] [-no_tmp_rsa]\n" | 1059 | " [-no_tls1_1] [-no_tls1_2] [-no_tls1_3] [-no_tmp_rsa]\n" |
| @@ -1084,6 +1092,7 @@ s_server_main(int argc, char *argv[]) | |||
| 1084 | memset(&s_server_config, 0, sizeof(s_server_config)); | 1092 | memset(&s_server_config, 0, sizeof(s_server_config)); |
| 1085 | s_server_config.keymatexportlen = 20; | 1093 | s_server_config.keymatexportlen = 20; |
| 1086 | s_server_config.meth = TLS_server_method(); | 1094 | s_server_config.meth = TLS_server_method(); |
| 1095 | s_server_config.naccept = -1; | ||
| 1087 | s_server_config.port = PORT; | 1096 | s_server_config.port = PORT; |
| 1088 | s_server_config.cert_file = TEST_CERT; | 1097 | s_server_config.cert_file = TEST_CERT; |
| 1089 | s_server_config.cert_file2 = TEST_CERT2; | 1098 | s_server_config.cert_file2 = TEST_CERT2; |
| @@ -1465,10 +1474,12 @@ s_server_main(int argc, char *argv[]) | |||
| 1465 | (void) BIO_flush(bio_s_out); | 1474 | (void) BIO_flush(bio_s_out); |
| 1466 | if (s_server_config.www) | 1475 | if (s_server_config.www) |
| 1467 | do_server(s_server_config.port, s_server_config.socket_type, | 1476 | do_server(s_server_config.port, s_server_config.socket_type, |
| 1468 | &accept_socket, www_body, s_server_config.context); | 1477 | &accept_socket, www_body, s_server_config.context, |
| 1478 | s_server_config.naccept); | ||
| 1469 | else | 1479 | else |
| 1470 | do_server(s_server_config.port, s_server_config.socket_type, | 1480 | do_server(s_server_config.port, s_server_config.socket_type, |
| 1471 | &accept_socket, sv_body, s_server_config.context); | 1481 | &accept_socket, sv_body, s_server_config.context, |
| 1482 | s_server_config.naccept); | ||
| 1472 | print_stats(bio_s_out, ctx); | 1483 | print_stats(bio_s_out, ctx); |
| 1473 | ret = 0; | 1484 | ret = 0; |
| 1474 | end: | 1485 | end: |
diff --git a/src/usr.bin/openssl/s_socket.c b/src/usr.bin/openssl/s_socket.c index 5d90fad8bb..f22c88d228 100644 --- a/src/usr.bin/openssl/s_socket.c +++ b/src/usr.bin/openssl/s_socket.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s_socket.c,v 1.11 2019/06/28 13:35:02 deraadt Exp $ */ | 1 | /* $OpenBSD: s_socket.c,v 1.12 2021/08/29 12:33:15 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -132,7 +132,7 @@ init_client(int *sock, char *host, char *port, int type, int af) | |||
| 132 | int | 132 | int |
| 133 | do_server(int port, int type, int *ret, | 133 | do_server(int port, int type, int *ret, |
| 134 | int (*cb) (char *hostname, int s, unsigned char *context), | 134 | int (*cb) (char *hostname, int s, unsigned char *context), |
| 135 | unsigned char *context) | 135 | unsigned char *context, int naccept) |
| 136 | { | 136 | { |
| 137 | int sock; | 137 | int sock; |
| 138 | char *name = NULL; | 138 | char *name = NULL; |
| @@ -161,7 +161,9 @@ do_server(int port, int type, int *ret, | |||
| 161 | shutdown(sock, SHUT_RDWR); | 161 | shutdown(sock, SHUT_RDWR); |
| 162 | close(sock); | 162 | close(sock); |
| 163 | } | 163 | } |
| 164 | if (i < 0) { | 164 | if (naccept != -1) |
| 165 | naccept--; | ||
| 166 | if (i < 0 || naccept == 0) { | ||
| 165 | shutdown(accept_socket, SHUT_RDWR); | 167 | shutdown(accept_socket, SHUT_RDWR); |
| 166 | close(accept_socket); | 168 | close(accept_socket); |
| 167 | return (i); | 169 | return (i); |
