diff options
author | jsing <> | 2021-03-17 18:08:32 +0000 |
---|---|---|
committer | jsing <> | 2021-03-17 18:08:32 +0000 |
commit | e1e6bd710141831f3f7a3926738ccb4ae42103fb (patch) | |
tree | 4009074b3e330a781c67b90419e631a63ddf8425 /src | |
parent | f117ae71ebe1eb8f946b06304b3843715ad808b0 (diff) | |
download | openbsd-e1e6bd710141831f3f7a3926738ccb4ae42103fb.tar.gz openbsd-e1e6bd710141831f3f7a3926738ccb4ae42103fb.tar.bz2 openbsd-e1e6bd710141831f3f7a3926738ccb4ae42103fb.zip |
Add DTLSv1.2 support to openssl(1) s_client/s_server.
ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/apps.c | 12 | ||||
-rw-r--r-- | src/usr.bin/openssl/openssl.1 | 16 | ||||
-rw-r--r-- | src/usr.bin/openssl/s_client.c | 61 | ||||
-rw-r--r-- | src/usr.bin/openssl/s_server.c | 74 |
4 files changed, 129 insertions, 34 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index 2c228aad59..24a28c7ca5 100644 --- a/src/usr.bin/openssl/apps.c +++ b/src/usr.bin/openssl/apps.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: apps.c,v 1.57 2020/10/26 11:48:39 tb Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.58 2021/03/17 18:08:32 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -141,12 +141,12 @@ | |||
141 | #include <openssl/err.h> | 141 | #include <openssl/err.h> |
142 | #include <openssl/pem.h> | 142 | #include <openssl/pem.h> |
143 | #include <openssl/pkcs12.h> | 143 | #include <openssl/pkcs12.h> |
144 | #include <openssl/rsa.h> | ||
144 | #include <openssl/safestack.h> | 145 | #include <openssl/safestack.h> |
146 | #include <openssl/ssl.h> | ||
145 | #include <openssl/x509.h> | 147 | #include <openssl/x509.h> |
146 | #include <openssl/x509v3.h> | 148 | #include <openssl/x509v3.h> |
147 | 149 | ||
148 | #include <openssl/rsa.h> | ||
149 | |||
150 | typedef struct { | 150 | typedef struct { |
151 | const char *name; | 151 | const char *name; |
152 | unsigned long flag; | 152 | unsigned long flag; |
@@ -2337,3 +2337,9 @@ show_cipher(const OBJ_NAME *name, void *arg) | |||
2337 | fprintf(stderr, " -%-24s%s", name->name, (++*n % 3 != 0 ? "" : "\n")); | 2337 | fprintf(stderr, " -%-24s%s", name->name, (++*n % 3 != 0 ? "" : "\n")); |
2338 | } | 2338 | } |
2339 | 2339 | ||
2340 | int | ||
2341 | SSL_is_dtls(const SSL *s) | ||
2342 | { | ||
2343 | return SSL_version(s) == DTLS1_VERSION || | ||
2344 | SSL_version(s) == DTLS1_2_VERSION; | ||
2345 | } | ||
diff --git a/src/usr.bin/openssl/openssl.1 b/src/usr.bin/openssl/openssl.1 index 9cd977c6d6..84627a84a5 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.128 2020/12/30 08:26:44 tb Exp $ | 1 | .\" $OpenBSD: openssl.1,v 1.129 2021/03/17 18:08:32 jsing 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: December 30 2020 $ | 113 | .Dd $Mdocdate: March 17 2021 $ |
114 | .Dt OPENSSL 1 | 114 | .Dt OPENSSL 1 |
115 | .Os | 115 | .Os |
116 | .Sh NAME | 116 | .Sh NAME |
@@ -4280,7 +4280,9 @@ Verify the input data and output the recovered data. | |||
4280 | .Op Fl crl_check_all | 4280 | .Op Fl crl_check_all |
4281 | .Op Fl crlf | 4281 | .Op Fl crlf |
4282 | .Op Fl debug | 4282 | .Op Fl debug |
4283 | .Op Fl dtls | ||
4283 | .Op Fl dtls1 | 4284 | .Op Fl dtls1 |
4285 | .Op Fl dtls1_2 | ||
4284 | .Op Fl extended_crl | 4286 | .Op Fl extended_crl |
4285 | .Op Fl groups Ar list | 4287 | .Op Fl groups Ar list |
4286 | .Op Fl host Ar host | 4288 | .Op Fl host Ar host |
@@ -4424,8 +4426,12 @@ Translate a line feed from the terminal into CR+LF, | |||
4424 | as required by some servers. | 4426 | as required by some servers. |
4425 | .It Fl debug | 4427 | .It Fl debug |
4426 | Print extensive debugging information, including a hex dump of all traffic. | 4428 | Print extensive debugging information, including a hex dump of all traffic. |
4429 | .It Fl dtls | ||
4430 | Permit any version of DTLS. | ||
4427 | .It Fl dtls1 | 4431 | .It Fl dtls1 |
4428 | Permit only DTLS1.0. | 4432 | Permit only DTLS1.0. |
4433 | .It Fl dtls1_2 | ||
4434 | Permit only DTLS1.2. | ||
4429 | .It Fl groups Ar list | 4435 | .It Fl groups Ar list |
4430 | Set the supported elliptic curve groups to the colon separated | 4436 | Set the supported elliptic curve groups to the colon separated |
4431 | .Ar list | 4437 | .Ar list |
@@ -4588,7 +4594,9 @@ will be used. | |||
4588 | .Op Fl dkey Ar file | 4594 | .Op Fl dkey Ar file |
4589 | .Op Fl dkeyform Cm der | pem | 4595 | .Op Fl dkeyform Cm der | pem |
4590 | .Op Fl dpass Ar arg | 4596 | .Op Fl dpass Ar arg |
4597 | .Op Fl dtls | ||
4591 | .Op Fl dtls1 | 4598 | .Op Fl dtls1 |
4599 | .Op Fl dtls1_2 | ||
4592 | .Op Fl groups Ar list | 4600 | .Op Fl groups Ar list |
4593 | .Op Fl HTTP | 4601 | .Op Fl HTTP |
4594 | .Op Fl id_prefix Ar arg | 4602 | .Op Fl id_prefix Ar arg |
@@ -4754,8 +4762,12 @@ load the parameters from the server certificate file. | |||
4754 | If this fails, a static set of parameters hard coded into the | 4762 | If this fails, a static set of parameters hard coded into the |
4755 | .Nm s_server | 4763 | .Nm s_server |
4756 | program will be used. | 4764 | program will be used. |
4765 | .It Fl dtls | ||
4766 | Permit any version of DTLS. | ||
4757 | .It Fl dtls1 | 4767 | .It Fl dtls1 |
4758 | Permit only DTLS1.0. | 4768 | Permit only DTLS1.0. |
4769 | .It Fl dtls1_2 | ||
4770 | Permit only DTLS1.2. | ||
4759 | .It Fl groups Ar list | 4771 | .It Fl groups Ar list |
4760 | Set the supported elliptic curve groups to the colon separated | 4772 | Set the supported elliptic curve groups to the colon separated |
4761 | .Ar list | 4773 | .Ar list |
diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c index eeeecff1bb..f03f8a9505 100644 --- a/src/usr.bin/openssl/s_client.c +++ b/src/usr.bin/openssl/s_client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s_client.c,v 1.52 2020/10/14 05:36:18 tb Exp $ */ | 1 | /* $OpenBSD: s_client.c,v 1.53 2021/03/17 18:08:32 jsing 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 | * |
@@ -260,7 +260,7 @@ s_client_opt_keymatexportlen(char *arg) | |||
260 | return (0); | 260 | return (0); |
261 | } | 261 | } |
262 | 262 | ||
263 | #ifndef OPENSSL_NO_DTLS1 | 263 | #ifndef OPENSSL_NO_DTLS |
264 | static int | 264 | static int |
265 | s_client_opt_mtu(char *arg) | 265 | s_client_opt_mtu(char *arg) |
266 | { | 266 | { |
@@ -285,11 +285,35 @@ s_client_opt_port(char *arg) | |||
285 | return (0); | 285 | return (0); |
286 | } | 286 | } |
287 | 287 | ||
288 | #ifndef OPENSSL_NO_DTLS | ||
289 | static int | ||
290 | s_client_opt_protocol_version_dtls(void) | ||
291 | { | ||
292 | s_client_config.meth = DTLS_client_method(); | ||
293 | s_client_config.socket_type = SOCK_DGRAM; | ||
294 | return (0); | ||
295 | } | ||
296 | #endif | ||
297 | |||
288 | #ifndef OPENSSL_NO_DTLS1 | 298 | #ifndef OPENSSL_NO_DTLS1 |
289 | static int | 299 | static int |
290 | s_client_opt_protocol_version_dtls1(void) | 300 | s_client_opt_protocol_version_dtls1(void) |
291 | { | 301 | { |
292 | s_client_config.meth = DTLS_client_method(); | 302 | s_client_config.meth = DTLS_client_method(); |
303 | s_client_config.min_version = DTLS1_VERSION; | ||
304 | s_client_config.max_version = DTLS1_VERSION; | ||
305 | s_client_config.socket_type = SOCK_DGRAM; | ||
306 | return (0); | ||
307 | } | ||
308 | #endif | ||
309 | |||
310 | #ifndef OPENSSL_NO_DTLS1_2 | ||
311 | static int | ||
312 | s_client_opt_protocol_version_dtls1_2(void) | ||
313 | { | ||
314 | s_client_config.meth = DTLS_client_method(); | ||
315 | s_client_config.min_version = DTLS1_2_VERSION; | ||
316 | s_client_config.max_version = DTLS1_2_VERSION; | ||
293 | s_client_config.socket_type = SOCK_DGRAM; | 317 | s_client_config.socket_type = SOCK_DGRAM; |
294 | return (0); | 318 | return (0); |
295 | } | 319 | } |
@@ -472,6 +496,14 @@ static const struct option s_client_options[] = { | |||
472 | .type = OPTION_FLAG, | 496 | .type = OPTION_FLAG, |
473 | .opt.flag = &s_client_config.debug, | 497 | .opt.flag = &s_client_config.debug, |
474 | }, | 498 | }, |
499 | #ifndef OPENSSL_NO_DTLS | ||
500 | { | ||
501 | .name = "dtls", | ||
502 | .desc = "Use any version of DTLS", | ||
503 | .type = OPTION_FUNC, | ||
504 | .opt.func = s_client_opt_protocol_version_dtls, | ||
505 | }, | ||
506 | #endif | ||
475 | #ifndef OPENSSL_NO_DTLS1 | 507 | #ifndef OPENSSL_NO_DTLS1 |
476 | { | 508 | { |
477 | .name = "dtls1", | 509 | .name = "dtls1", |
@@ -480,6 +512,14 @@ static const struct option s_client_options[] = { | |||
480 | .opt.func = s_client_opt_protocol_version_dtls1, | 512 | .opt.func = s_client_opt_protocol_version_dtls1, |
481 | }, | 513 | }, |
482 | #endif | 514 | #endif |
515 | #ifndef OPENSSL_NO_DTLS1_2 | ||
516 | { | ||
517 | .name = "dtls1_2", | ||
518 | .desc = "Just use DTLSv1.2", | ||
519 | .type = OPTION_FUNC, | ||
520 | .opt.func = s_client_opt_protocol_version_dtls1_2, | ||
521 | }, | ||
522 | #endif | ||
483 | { | 523 | { |
484 | .name = "groups", | 524 | .name = "groups", |
485 | .argname = "list", | 525 | .argname = "list", |
@@ -546,7 +586,7 @@ static const struct option s_client_options[] = { | |||
546 | .type = OPTION_FLAG, | 586 | .type = OPTION_FLAG, |
547 | .opt.flag = &s_client_config.msg, | 587 | .opt.flag = &s_client_config.msg, |
548 | }, | 588 | }, |
549 | #ifndef OPENSSL_NO_DTLS1 | 589 | #ifndef OPENSSL_NO_DTLS |
550 | { | 590 | { |
551 | .name = "mtu", | 591 | .name = "mtu", |
552 | .argname = "mtu", | 592 | .argname = "mtu", |
@@ -745,7 +785,7 @@ static const struct option s_client_options[] = { | |||
745 | .type = OPTION_FLAG, | 785 | .type = OPTION_FLAG, |
746 | .opt.flag = &s_client_config.status_req, | 786 | .opt.flag = &s_client_config.status_req, |
747 | }, | 787 | }, |
748 | #ifndef OPENSSL_NO_DTLS1 | 788 | #ifndef OPENSSL_NO_DTLS |
749 | { | 789 | { |
750 | .name = "timeout", | 790 | .name = "timeout", |
751 | .desc = "Enable send/receive timeout on DTLS connections", | 791 | .desc = "Enable send/receive timeout on DTLS connections", |
@@ -828,7 +868,7 @@ sc_usage(void) | |||
828 | "[-4 | -6] [-alpn protocols] [-bugs] [-CAfile file]\n" | 868 | "[-4 | -6] [-alpn protocols] [-bugs] [-CAfile file]\n" |
829 | " [-CApath directory] [-cert file] [-certform der | pem] [-check_ss_sig]\n" | 869 | " [-CApath directory] [-cert file] [-certform der | pem] [-check_ss_sig]\n" |
830 | " [-cipher cipherlist] [-connect host[:port]] [-crl_check]\n" | 870 | " [-cipher cipherlist] [-connect host[:port]] [-crl_check]\n" |
831 | " [-crl_check_all] [-crlf] [-debug] [-dtls1] [-extended_crl]\n" | 871 | " [-crl_check_all] [-crlf] [-debug] [-dtls] [-dtls1] [-dtls1_2] [-extended_crl]\n" |
832 | " [-groups list] [-host host] [-ign_eof] [-ignore_critical]\n" | 872 | " [-groups list] [-host host] [-ign_eof] [-ignore_critical]\n" |
833 | " [-issuer_checks] [-key keyfile] [-keyform der | pem]\n" | 873 | " [-issuer_checks] [-key keyfile] [-keyform der | pem]\n" |
834 | " [-keymatexport label] [-keymatexportlen len] [-legacy_server_connect]\n" | 874 | " [-keymatexport label] [-keymatexportlen len] [-legacy_server_connect]\n" |
@@ -1090,8 +1130,7 @@ s_client_main(int argc, char **argv) | |||
1090 | if (s_client_config.pause & 0x01) | 1130 | if (s_client_config.pause & 0x01) |
1091 | SSL_set_debug(con, 1); | 1131 | SSL_set_debug(con, 1); |
1092 | 1132 | ||
1093 | if (SSL_version(con) == DTLS1_VERSION) { | 1133 | if (SSL_is_dtls(con)) { |
1094 | |||
1095 | sbio = BIO_new_dgram(s, BIO_NOCLOSE); | 1134 | sbio = BIO_new_dgram(s, BIO_NOCLOSE); |
1096 | if (getsockname(s, (struct sockaddr *)&peer, | 1135 | if (getsockname(s, (struct sockaddr *)&peer, |
1097 | (void *)&peerlen) == -1) { | 1136 | (void *)&peerlen) == -1) { |
@@ -1290,8 +1329,7 @@ s_client_main(int argc, char **argv) | |||
1290 | struct pollfd pfd[3]; /* stdin, stdout, socket */ | 1329 | struct pollfd pfd[3]; /* stdin, stdout, socket */ |
1291 | int ptimeout = -1; | 1330 | int ptimeout = -1; |
1292 | 1331 | ||
1293 | if ((SSL_version(con) == DTLS1_VERSION) && | 1332 | if (SSL_is_dtls(con) && DTLSv1_get_timeout(con, &timeout)) |
1294 | DTLSv1_get_timeout(con, &timeout)) | ||
1295 | ptimeout = timeout.tv_sec * 1000 + | 1333 | ptimeout = timeout.tv_sec * 1000 + |
1296 | timeout.tv_usec / 1000; | 1334 | timeout.tv_usec / 1000; |
1297 | 1335 | ||
@@ -1370,10 +1408,9 @@ s_client_main(int argc, char **argv) | |||
1370 | /* goto end; */ | 1408 | /* goto end; */ |
1371 | } | 1409 | } |
1372 | } | 1410 | } |
1373 | if ((SSL_version(con) == DTLS1_VERSION) && | 1411 | if (SSL_is_dtls(con) && |
1374 | DTLSv1_handle_timeout(con) > 0) { | 1412 | DTLSv1_handle_timeout(con) > 0) |
1375 | BIO_printf(bio_err, "TIMEOUT occured\n"); | 1413 | BIO_printf(bio_err, "TIMEOUT occured\n"); |
1376 | } | ||
1377 | if (!ssl_pending && | 1414 | if (!ssl_pending && |
1378 | (pfd[2].revents & (POLLOUT|POLLERR|POLLNVAL))) { | 1415 | (pfd[2].revents & (POLLOUT|POLLERR|POLLNVAL))) { |
1379 | if (pfd[2].revents & (POLLERR|POLLNVAL)) { | 1416 | if (pfd[2].revents & (POLLERR|POLLNVAL)) { |
diff --git a/src/usr.bin/openssl/s_server.c b/src/usr.bin/openssl/s_server.c index 4d4bed60ac..6009b584bf 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.44 2020/10/02 15:43:48 tb Exp $ */ | 1 | /* $OpenBSD: s_server.c,v 1.45 2021/03/17 18:08:32 jsing 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 | * |
@@ -239,7 +239,7 @@ static struct { | |||
239 | int bugs; | 239 | int bugs; |
240 | char *CAfile; | 240 | char *CAfile; |
241 | char *CApath; | 241 | char *CApath; |
242 | #ifndef OPENSSL_NO_DTLS1 | 242 | #ifndef OPENSSL_NO_DTLS |
243 | int cert_chain; | 243 | int cert_chain; |
244 | #endif | 244 | #endif |
245 | char *cert_file; | 245 | char *cert_file; |
@@ -315,7 +315,7 @@ s_server_opt_keymatexportlen(char *arg) | |||
315 | return (0); | 315 | return (0); |
316 | } | 316 | } |
317 | 317 | ||
318 | #ifndef OPENSSL_NO_DTLS1 | 318 | #ifndef OPENSSL_NO_DTLS |
319 | static int | 319 | static int |
320 | s_server_opt_mtu(char *arg) | 320 | s_server_opt_mtu(char *arg) |
321 | { | 321 | { |
@@ -328,9 +328,11 @@ s_server_opt_mtu(char *arg) | |||
328 | } | 328 | } |
329 | return (0); | 329 | return (0); |
330 | } | 330 | } |
331 | #endif | ||
331 | 332 | ||
333 | #ifndef OPENSSL_NO_DTLS | ||
332 | static int | 334 | static int |
333 | s_server_protocol_version_dtls1(void) | 335 | s_server_opt_protocol_version_dtls(void) |
334 | { | 336 | { |
335 | s_server_config.meth = DTLS_server_method(); | 337 | s_server_config.meth = DTLS_server_method(); |
336 | s_server_config.socket_type = SOCK_DGRAM; | 338 | s_server_config.socket_type = SOCK_DGRAM; |
@@ -338,6 +340,30 @@ s_server_protocol_version_dtls1(void) | |||
338 | } | 340 | } |
339 | #endif | 341 | #endif |
340 | 342 | ||
343 | #ifndef OPENSSL_NO_DTLS1 | ||
344 | static int | ||
345 | s_server_opt_protocol_version_dtls1(void) | ||
346 | { | ||
347 | s_server_config.meth = DTLS_server_method(); | ||
348 | s_server_config.min_version = DTLS1_VERSION; | ||
349 | s_server_config.max_version = DTLS1_VERSION; | ||
350 | s_server_config.socket_type = SOCK_DGRAM; | ||
351 | return (0); | ||
352 | } | ||
353 | #endif | ||
354 | |||
355 | #ifndef OPENSSL_NO_DTLS1_2 | ||
356 | static int | ||
357 | s_server_opt_protocol_version_dtls1_2(void) | ||
358 | { | ||
359 | s_server_config.meth = DTLS_server_method(); | ||
360 | s_server_config.min_version = DTLS1_2_VERSION; | ||
361 | s_server_config.max_version = DTLS1_2_VERSION; | ||
362 | s_server_config.socket_type = SOCK_DGRAM; | ||
363 | return (0); | ||
364 | } | ||
365 | #endif | ||
366 | |||
341 | static int | 367 | static int |
342 | s_server_protocol_version_tls1(void) | 368 | s_server_protocol_version_tls1(void) |
343 | { | 369 | { |
@@ -538,7 +564,7 @@ static const struct option s_server_options[] = { | |||
538 | .type = OPTION_ARG_FORMAT, | 564 | .type = OPTION_ARG_FORMAT, |
539 | .opt.value = &s_server_config.cert_format, | 565 | .opt.value = &s_server_config.cert_format, |
540 | }, | 566 | }, |
541 | #ifndef OPENSSL_NO_DTLS1 | 567 | #ifndef OPENSSL_NO_DTLS |
542 | { | 568 | { |
543 | .name = "chain", | 569 | .name = "chain", |
544 | .type = OPTION_FLAG, | 570 | .type = OPTION_FLAG, |
@@ -613,12 +639,28 @@ static const struct option s_server_options[] = { | |||
613 | .type = OPTION_ARG, | 639 | .type = OPTION_ARG, |
614 | .opt.arg = &s_server_config.dpassarg, | 640 | .opt.arg = &s_server_config.dpassarg, |
615 | }, | 641 | }, |
642 | #ifndef OPENSSL_NO_DTLS | ||
643 | { | ||
644 | .name = "dtls", | ||
645 | .desc = "Use any version of DTLS", | ||
646 | .type = OPTION_FUNC, | ||
647 | .opt.func = s_server_opt_protocol_version_dtls, | ||
648 | }, | ||
649 | #endif | ||
616 | #ifndef OPENSSL_NO_DTLS1 | 650 | #ifndef OPENSSL_NO_DTLS1 |
617 | { | 651 | { |
618 | .name = "dtls1", | 652 | .name = "dtls1", |
619 | .desc = "Just talk DTLSv1", | 653 | .desc = "Just use DTLSv1", |
620 | .type = OPTION_FUNC, | 654 | .type = OPTION_FUNC, |
621 | .opt.func = s_server_protocol_version_dtls1, | 655 | .opt.func = s_server_opt_protocol_version_dtls1, |
656 | }, | ||
657 | #endif | ||
658 | #ifndef OPENSSL_NO_DTLS1_2 | ||
659 | { | ||
660 | .name = "dtls1_2", | ||
661 | .desc = "Just use DTLSv1.2", | ||
662 | .type = OPTION_FUNC, | ||
663 | .opt.func = s_server_opt_protocol_version_dtls1_2, | ||
622 | }, | 664 | }, |
623 | #endif | 665 | #endif |
624 | { | 666 | { |
@@ -689,7 +731,7 @@ static const struct option s_server_options[] = { | |||
689 | .type = OPTION_FLAG, | 731 | .type = OPTION_FLAG, |
690 | .opt.flag = &s_server_config.msg, | 732 | .opt.flag = &s_server_config.msg, |
691 | }, | 733 | }, |
692 | #ifndef OPENSSL_NO_DTLS1 | 734 | #ifndef OPENSSL_NO_DTLS |
693 | { | 735 | { |
694 | .name = "mtu", | 736 | .name = "mtu", |
695 | .argname = "mtu", | 737 | .argname = "mtu", |
@@ -876,7 +918,7 @@ static const struct option s_server_options[] = { | |||
876 | .type = OPTION_FUNC, | 918 | .type = OPTION_FUNC, |
877 | .opt.func = s_server_opt_status_verbose, | 919 | .opt.func = s_server_opt_status_verbose, |
878 | }, | 920 | }, |
879 | #ifndef OPENSSL_NO_DTLS1 | 921 | #ifndef OPENSSL_NO_DTLS |
880 | { | 922 | { |
881 | .name = "timeout", | 923 | .name = "timeout", |
882 | .desc = "Enable timeouts", | 924 | .desc = "Enable timeouts", |
@@ -1000,7 +1042,7 @@ sv_usage(void) | |||
1000 | " [-context id] [-crl_check] [-crl_check_all] [-crlf]\n" | 1042 | " [-context id] [-crl_check] [-crl_check_all] [-crlf]\n" |
1001 | " [-dcert file] [-dcertform der | pem] [-debug]\n" | 1043 | " [-dcert file] [-dcertform der | pem] [-debug]\n" |
1002 | " [-dhparam file] [-dkey file] [-dkeyform der | pem]\n" | 1044 | " [-dhparam file] [-dkey file] [-dkeyform der | pem]\n" |
1003 | " [-dpass arg] [-dtls1] [-groups list] [-HTTP]\n" | 1045 | " [-dpass arg] [-dtls] [-dtls1] [-dtls1_2] [-groups list] [-HTTP]\n" |
1004 | " [-id_prefix arg] [-key keyfile] [-key2 keyfile]\n" | 1046 | " [-id_prefix arg] [-key keyfile] [-key2 keyfile]\n" |
1005 | " [-keyform der | pem] [-keymatexport label]\n" | 1047 | " [-keyform der | pem] [-keymatexport label]\n" |
1006 | " [-keymatexportlen len] [-msg] [-mtu mtu]\n" | 1048 | " [-keymatexportlen len] [-msg] [-mtu mtu]\n" |
@@ -1535,8 +1577,7 @@ sv_body(char *hostname, int s, unsigned char *context) | |||
1535 | } | 1577 | } |
1536 | SSL_clear(con); | 1578 | SSL_clear(con); |
1537 | 1579 | ||
1538 | if (SSL_version(con) == DTLS1_VERSION) { | 1580 | if (SSL_is_dtls(con)) { |
1539 | |||
1540 | sbio = BIO_new_dgram(s, BIO_NOCLOSE); | 1581 | sbio = BIO_new_dgram(s, BIO_NOCLOSE); |
1541 | 1582 | ||
1542 | if (s_server_config.enable_timeouts) { | 1583 | if (s_server_config.enable_timeouts) { |
@@ -1602,7 +1643,7 @@ sv_body(char *hostname, int s, unsigned char *context) | |||
1602 | pfd[1].fd = s; | 1643 | pfd[1].fd = s; |
1603 | pfd[1].events = POLLIN; | 1644 | pfd[1].events = POLLIN; |
1604 | 1645 | ||
1605 | if ((SSL_version(con) == DTLS1_VERSION) && | 1646 | if (SSL_is_dtls(con) && |
1606 | DTLSv1_get_timeout(con, &timeout)) | 1647 | DTLSv1_get_timeout(con, &timeout)) |
1607 | ptimeout = timeout.tv_sec * 1000 + | 1648 | ptimeout = timeout.tv_sec * 1000 + |
1608 | timeout.tv_usec / 1000; | 1649 | timeout.tv_usec / 1000; |
@@ -1611,10 +1652,9 @@ sv_body(char *hostname, int s, unsigned char *context) | |||
1611 | 1652 | ||
1612 | i = poll(pfd, 2, ptimeout); | 1653 | i = poll(pfd, 2, ptimeout); |
1613 | 1654 | ||
1614 | if ((SSL_version(con) == DTLS1_VERSION) && | 1655 | if (SSL_is_dtls(con) && |
1615 | DTLSv1_handle_timeout(con) > 0) { | 1656 | DTLSv1_handle_timeout(con) > 0) |
1616 | BIO_printf(bio_err, "TIMEOUT occured\n"); | 1657 | BIO_printf(bio_err, "TIMEOUT occured\n"); |
1617 | } | ||
1618 | if (i <= 0) | 1658 | if (i <= 0) |
1619 | continue; | 1659 | continue; |
1620 | if (pfd[0].revents) { | 1660 | if (pfd[0].revents) { |
@@ -1660,7 +1700,7 @@ sv_body(char *hostname, int s, unsigned char *context) | |||
1660 | } | 1700 | } |
1661 | if ((i <= 0) || (buf[0] == 'q')) { | 1701 | if ((i <= 0) || (buf[0] == 'q')) { |
1662 | BIO_printf(bio_s_out, "DONE\n"); | 1702 | BIO_printf(bio_s_out, "DONE\n"); |
1663 | if (SSL_version(con) != DTLS1_VERSION) { | 1703 | if (!SSL_is_dtls(con)) { |
1664 | shutdown(s, SHUT_RD); | 1704 | shutdown(s, SHUT_RD); |
1665 | close(s); | 1705 | close(s); |
1666 | } | 1706 | } |