<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<div></div>
<p dir="auto">Running a GnuTLS 3.6.3 DTLS client, if the server's <code>NewSessionTicket</code> gets lost while the <code>ChangeCipherSpec</code> goes through, the client does not request retransmission by retransmitting his last flight, and the handshake comes to halt.</p>
<p dir="auto">Steps to reproduce using Mbed TLS 2.7, from within the Mbed TLS base directory:</p>
<ul dir="auto">
<li>Run UDP proxy emulating a lossy network <code>./programs/tests/udp_proxy server_addr=localhost server_port=10000 listen_addr=localhost listen_port=20000 drop=5 delay=5 duplicate=5 seed=14</code>
</li>
<li>Run Mbed TLS server <code>./programs/ssl/ssl_server2 dtls=1 server_addr=localhost server_port=10000 crt_file=tests/data_files/server5.crt key_file=tests/data_files/server5.key</code>
</li>
<li>Run GnuTLS 3.6.3 client <code>GNUTLS_DIR/gnutls-cli --udp --port=20000 --insecure localhost</code>
</li>
</ul>
<p dir="auto">The proxy log shows that the <code>NewSessionTicket</code> message gets dropped, while the <code>ChangeCipherSpec</code> goes through.</p>
<p dir="auto">Looking at the code, the following might be the reason:</p>
<ul dir="auto">
<li>When <code>_gnutls_recv_new_session_ticket()</code> is called first, it finds a CCS, which seems to be ignored but not dropped, see <a href="https://github.com/gnutls/gnutls/blob/gnutls_3_6_3/lib/buffers.c#L1294" rel="nofollow noreferrer noopener" target="_blank">here</a>.</li>
<li>When <code>_gnutls_recv_new_session_ticket()</code> is called again, the <a href="https://github.com/gnutls/gnutls/blob/gnutls_3_6_3/lib/ext/session_ticket.c#L726" rel="nofollow noreferrer noopener" target="_blank">retransmission timeout check</a> is omitted because <code>gnutls_record_check_pending()</code> signals the pending CCS. This leads to <code>_gnutls_io_recv_int()</code> being called, which as far as I see falls down to <code>_gnutls_recv_in_buffers</code> <a href="https://github.com/gnutls/gnutls/blob/gnutls_3_6_3/lib/buffers.c#L1423" rel="nofollow noreferrer noopener" target="_blank">here</a> as the calls to <code>get_last_packet()</code> return <code>EAGAIN</code>. The timeout for the call to <code>_gnutls_recv_in_buffers</code> is the entire remaining maximum handshake time, and not the retransmission timeout (in the test ~38s), hence the handshake comes to a halt.</li>
</ul>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">
—
<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/issues/543">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/sent_notifications/dab9fa2bf60f57e8b2ee4d975918b777/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/issues/543"}}</script>
</p>
</div>
</body>
</html>