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
ERRORWith 3.5.x on Windows, and with 4.0.2 on Linux, the server retransmits its flight and the handshake completes.
Steps to reproduce
- Start the server on Windows:
openssl s_server -accept 5514 -dtls1_2 -listen -cert server.pem -key server.key -state - 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_2behind a small UDP relay that delays client -> server packets by 1.5 s. - 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 setdgram_adjust_rcv_timeout()setsSO_RCVTIMEOto the DTLS timer. On Windows the timeout is reported asWSAETIMEDOUT, whichBIO_dgram_non_fatal_error()does not treat as retryable. On Linux it isEAGAIN, which is retryable.- Before 4.0 this was harmless:
dtls1_read_failed()saw the expired timer and calleddtls1_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 becauseossl_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.
Source: openssl/openssl