Skip to content

Commit 08b89fb

Browse files
committed
server: add optional argument to -J disable hrr cookie
1 parent 401cfbd commit 08b89fb

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

examples/server/server.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ static const char* server_usage_msg[][65] = {
936936
"-Q Request certificate from client post-handshake\n", /* 49 */
937937
#endif
938938
#ifdef WOLFSSL_SEND_HRR_COOKIE
939-
"-J Server sends Cookie Extension containing state\n", /* 50 */
939+
"-J [n] Server sends Cookie Extension containing state (n to "
940+
"disable)\n", /* 50 */
940941
#endif
941942
#endif /* WOLFSSL_TLS13 */
942943
#ifdef WOLFSSL_EARLY_DATA
@@ -1702,7 +1703,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
17021703
/* Not Used: h, z, W, X */
17031704
while ((ch = mygetopt_long(argc, argv, "?:"
17041705
"abc:defgijk:l:mop:q:rstu;v:wxy"
1705-
"A:B:C:D:E:FGH:IJKL:MNO:PQR:S:T;UVYZ:"
1706+
"A:B:C:D:E:FGH:IJ;KL:MNO:PQR:S:T;UVYZ:"
17061707
"01:23:4:567:89"
17071708
"@#", long_options, 0)) != -1) {
17081709
switch (ch) {
@@ -2085,6 +2086,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
20852086
case 'J' :
20862087
#ifdef WOLFSSL_SEND_HRR_COOKIE
20872088
hrrCookie = 1;
2089+
if (XSTRCMP(myoptarg, "n") == 0)
2090+
hrrCookie = -1;
20882091
#endif
20892092
break;
20902093

@@ -2959,10 +2962,13 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
29592962
#endif /* !NO_CERTS */
29602963

29612964
#ifdef WOLFSSL_SEND_HRR_COOKIE
2962-
if (hrrCookie && wolfSSL_send_hrr_cookie(ssl, NULL, 0)
2965+
if (hrrCookie == 1 && wolfSSL_send_hrr_cookie(ssl, NULL, 0)
29632966
!= WOLFSSL_SUCCESS) {
29642967
err_sys("unable to set use of cookie with HRR msg");
29652968
}
2969+
else if (hrrCookie == -1) {
2970+
wolfSSL_disable_hrr_cookie(ssl);
2971+
}
29662972
#endif
29672973

29682974
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL)

tests/test-dtls13.conf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,16 @@
129129
-l TLS13-AES128-GCM-SHA256
130130
-J
131131

132-
# server DTLSv1.3
132+
# server DTLSv1.3 HelloRetryRequest with cookie
133133
-v 4
134134
-u
135135
-l TLS13-AES128-GCM-SHA256
136136
-J
137137

138-
# client DTLSv1.3 HelloRetryRequest with cookie
138+
# client DTLSv1.3
139139
-v 4
140140
-u
141141
-l TLS13-AES128-GCM-SHA256
142-
-J
143142

144143
# server DTLSv1.3
145144
-v 4
@@ -260,3 +259,14 @@
260259
-u
261260
-l TLS13-AES128-GCM-SHA256
262261
-f
262+
263+
# server DTLSv1.3 no HelloRetryRequest cookie
264+
-u
265+
-v 4
266+
-l TLS_AES_128_GCM_SHA256
267+
-J n
268+
269+
# client DTLSv1.3 defaults
270+
-u
271+
-v 4
272+
-l TLS_AES_128_GCM_SHA256

0 commit comments

Comments
 (0)