#32979·openssl

DTLS server on Windows aborts handshake when the retransmit timer expires (4.0 regression, WSAETIMEDOUT treated as fatal)

Author: htahabenderliCreated Sep 24, 2026Updated Sep 28, 2026
Labelsbranch: masterhelp wantedtriaged: bugbranch: 4.0branch: 4.1

Version / platform

  • OpenSSL 4.0.2 (also 4.0.0), Windows 11 x64. Reproduced with both the native MSVC build and a mingw64 build.
  • Not reproducible with 3.5.x on Windows, or with 4.0.2 on Linux.

Description

A DTLS 1.2 server on Windows aborts the handshake if the client takes longer than the initial retransmit timeout (~1 s) to send its second flight (ClientKeyExchange/CCS/Finished). Instead of retransmitting its flight, the server fails with no alert:

SSL_accept:SSLv3/TLS write server done
read from ... (16721 bytes => -1)
SSL_accept:error in error
ERROR

With 3.5.x on Windows, and with 4.0.2 on Linux, the server retransmits its flight and the handshake completes.

Steps to reproduce

  1. Start the server on Windows: openssl s_server -accept 5514 -dtls1_2 -listen -cert server.pem -key server.key -state
  2. Connect with a DTLS 1.2 client that takes more than 1 s to answer the ServerHelloDone. We hit this with an embedded client (ECDHE + RSA verification takes ~1.5 s). It also reproduces with openssl s_client -dtls1_2 behind a small UDP relay that delays client -> server packets by 1.5 s.
  3. The handshake fails. With a delay under ~1 s it succeeds.

Analysis

Instrumenting dgram_read() in crypto/bio/bss_dgram.c shows:

recvfrom ret=-1 WSAGetLastError=10060 (WSAETIMEDOUT) SO_RCVTIMEO=1000ms blocked=1000ms
BIO_dgram_should_retry=0 -> no retry flag set
  • dgram_adjust_rcv_timeout() sets SO_RCVTIMEO to the DTLS timer. On Windows the timeout is reported as WSAETIMEDOUT, which BIO_dgram_non_fatal_error() does not treat as retryable. On Linux it is EAGAIN, which is retryable.
  • Before 4.0 this was harmless: dtls1_read_failed() saw the expired timer and called dtls1_handle_timeout().
  • Since commit ebb188f0 (#30230, "Ensure fatal errors from the record layer put the state machine into err"), ossl_statem_send_fatal(s, SSL_AD_NO_ALERT) puts the connection into an error state first. dtls1_read_failed() then returns early because ossl_statem_in_error(s) is true, and no retransmission happens.
  • Removing that single line from 4.0.2 restores the 3.5 behaviour. That is only a diagnostic, not a proposed fix.

A related detail: BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP checks data->_errno == WSAETIMEDOUT on Windows, but _errno is only stored when the error is considered retryable, so that check can never be true on Windows.