dtls_server: allow unexpected messages during handshake

If MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE happens during the handshake, don't
show it as an "error". It might be an error, but it might also be a fact of
life if it happens during the second or more handshake: it can be a
duplicated packet or a close_notify alert from the previous connection,
which is hard to avoid and harmless.

Fixes #9652.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2024-10-01 12:44:33 +02:00
parent 55b43e5cfb
commit 62163142a0

View File

@ -291,7 +291,14 @@ reset:
ret = 0;
goto reset;
} else if (ret != 0) {
printf(" failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", (unsigned int) -ret);
printf(" failed\n ! mbedtls_ssl_handshake returned -0x%x\n", (unsigned int) -ret);
if (ret == MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE) {
printf(" An unexpected message was received from our peer. If this happened at\n");
printf(" the beginning of the handshake, this is likely a duplicated packet or\n");
printf(" a close_notify alert from the previous connection, which is harmless.\n");
ret = 0;
}
printf("\n");
goto reset;
}