@@ -5775,7 +5775,14 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
57755775 ) {
57765776 /* RFC 9147 Section 5.3 / RFC 9001 Section 8.4: DTLS 1.3 and QUIC
57775777 * ServerHello must have empty legacy_session_id_echo. */
5778- if (args->sessIdSz != 0) {
5778+ int requireEmptyEcho = 1;
5779+ #ifdef WOLFSSL_DTLS13_5_9_0_COMPAT
5780+ /* Compat: a wolfSSL <= 5.9.0 DTLS 1.3 server echoes the client's
5781+ * legacy_session_id; accept any echo. */
5782+ if (ssl->options.dtls)
5783+ requireEmptyEcho = 0;
5784+ #endif
5785+ if (requireEmptyEcho && args->sessIdSz != 0) {
57795786 WOLFSSL_MSG("args->sessIdSz != 0");
57805787 WOLFSSL_ERROR_VERBOSE(INVALID_PARAMETER);
57815788 return INVALID_PARAMETER;
@@ -6979,7 +6986,7 @@ static int RestartHandshakeHashWithCookie(WOLFSSL* ssl, Cookie* cookie)
69796986
69806987 /* Reconstruct the HelloRetryMessage for handshake hash. */
69816988 sessIdSz = ssl->session->sessionIDSz;
6982- #ifdef WOLFSSL_DTLS13
6989+ #if defined( WOLFSSL_DTLS13) && !defined(WOLFSSL_DTLS13_5_9_0_COMPAT)
69836990 /* RFC 9147 Section 5.3: DTLS 1.3 must use empty legacy_session_id. */
69846991 if (ssl->options.dtls)
69856992 sessIdSz = 0;
@@ -7459,7 +7466,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
74597466 if (sessIdSz + args->idx > helloSz)
74607467 ERROR_OUT(BUFFER_ERROR, exit_dch);
74617468
7462- #ifdef WOLFSSL_DTLS13
7469+ #if defined( WOLFSSL_DTLS13) && !defined(WOLFSSL_DTLS13_5_9_0_COMPAT)
74637470 /* RFC 9147 Section 5.3: DTLS 1.3 ServerHello must have empty
74647471 * legacy_session_id_echo. Don't store the client's value so it
74657472 * won't be echoed in SendTls13ServerHello. */
@@ -8064,7 +8071,7 @@ int SendTls13ServerHello(WOLFSSL* ssl, byte extMsgType)
80648071 WOLFSSL_BUFFER(ssl->arrays->serverRandom, RAN_LEN);
80658072#endif
80668073
8067- #ifdef WOLFSSL_DTLS13
8074+ #if defined( WOLFSSL_DTLS13) && !defined(WOLFSSL_DTLS13_5_9_0_COMPAT)
80688075 if (ssl->options.dtls) {
80698076 /* RFC 9147 Section 5.3: DTLS 1.3 ServerHello must have empty
80708077 * legacy_session_id_echo. */
0 commit comments