Skip to content

avformat/tls_mbedtls: fix DTLS handshake failure when receiving non-D…#77

Open
JackLau1222 wants to merge 1 commit into
workflowsfrom
Nariman-Sayed-fix/tls-mbedtls-dtls-stun-filter-v3
Open

avformat/tls_mbedtls: fix DTLS handshake failure when receiving non-D…#77
JackLau1222 wants to merge 1 commit into
workflowsfrom
Nariman-Sayed-fix/tls-mbedtls-dtls-stun-filter-v3

Conversation

@JackLau1222

Copy link
Copy Markdown
Collaborator

…TLS packets

Some WebRTC servers such as Pion send STUN packets concurrently during the DTLS handshake. Unlike OpenSSL and GnuTLS which filter non-DTLS packets internally, mbedtls passes all received UDP packets directly to its DTLS state machine, causing the handshake to fail.

Fix this by adding ff_is_dtls_packet() to tls.c to check the DTLS record layer header, and using it in mbedtls_recv to discard non-DTLS packets such as STUN by returning WANT_READ, as specified by RFC 5764 Section 5.1.2. This function is also used in whip.c.

…TLS packets

Some WebRTC servers such as Pion send STUN packets concurrently during
the DTLS handshake. Unlike OpenSSL and GnuTLS which filter non-DTLS
packets internally, mbedtls passes all received UDP packets directly to
its DTLS state machine, causing the handshake to fail.

Fix this by adding ff_is_dtls_packet() to tls.c to check the DTLS
record layer header, and using it in mbedtls_recv to discard non-DTLS
packets such as STUN by returning WANT_READ, as specified by
RFC 5764 Section 5.1.2. This function is also used in whip.c.

Signed-off-by: Nariman-Sayed <narimansayed28@gmail.com>
@github-actions
github-actions Bot force-pushed the workflows branch 7 times, most recently from 2a8238f to 6c06cf8 Compare May 11, 2026 00:39
@github-actions
github-actions Bot force-pushed the workflows branch 7 times, most recently from ea01160 to ef1af6f Compare May 18, 2026 00:42
@github-actions
github-actions Bot force-pushed the workflows branch 8 times, most recently from 57bf5b8 to 7cfa7c0 Compare May 26, 2026 00:42
@github-actions
github-actions Bot force-pushed the workflows branch 7 times, most recently from 436b8ba to f7516d1 Compare June 2, 2026 00:49
@github-actions
github-actions Bot force-pushed the workflows branch 7 times, most recently from 433b564 to e3a07fc Compare June 20, 2026 00:46
@github-actions
github-actions Bot force-pushed the workflows branch 8 times, most recently from 5e533d1 to 2525990 Compare June 28, 2026 00:45
@github-actions
github-actions Bot force-pushed the workflows branch 7 times, most recently from 05910b9 to 5db5ac9 Compare July 5, 2026 02:43
@github-actions
github-actions Bot force-pushed the workflows branch 8 times, most recently from 4ac181a to b7d0383 Compare July 13, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants