-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tls: use monotonic timer for monitoring DTLS peer inactivity #450
tls: use monotonic timer for monitoring DTLS peer inactivity #450
Conversation
🎉 Thank you for your code contribution! To guarantee the change/addition is conformant to the OCF Specification, we would like to ask you to execute OCF Conformance Testing of your change ☝️ when your work is ready to be reviewed. ℹ️ To verify your latest change (45e83b9), label this PR with |
4577be9
to
2d295c6
Compare
4f90c22
to
029bd1d
Compare
900f6a5
to
651a5f2
Compare
651a5f2
to
c8006b3
Compare
c8006b3
to
9c9a386
Compare
if ((peer->endpoint.flags & TCP) == 0) { | ||
mbedtls_ssl_close_notify(&peer->ssl_ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From this code it seems to be more general - not only for DTLS (udp tls), but also for TLS (TCP) connection
mbedtls_ssl_set_timer_cb(&peer->ssl_ctx, &peer->timer, ssl_set_timer, | ||
ssl_get_timer); | ||
oc_ri_add_timed_event_callback_seconds( | ||
peer, oc_tls_inactive, (oc_clock_time_t)OC_DTLS_INACTIVITY_TIMEOUT); | ||
oc_ri_add_timed_event_callback_ticks(peer, oc_dtls_inactive, | ||
DTLS_INACTIVITY_TIMEOUT_TICKS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now I see the limitation to DTLS
mbedtls_ssl_set_timer_cb(&peer->ssl_ctx, &peer->timer, ssl_set_timer, | ||
ssl_get_timer); | ||
oc_ri_add_timed_event_callback_seconds( | ||
peer, oc_tls_inactive, (oc_clock_time_t)OC_DTLS_INACTIVITY_TIMEOUT); | ||
oc_ri_add_timed_event_callback_ticks(peer, oc_dtls_inactive, | ||
DTLS_INACTIVITY_TIMEOUT_TICKS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this timer could be used to close also TCP-TLS connection when we implement the closing idle sessions for TCP
not in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm checking the header for mbedtls_ssl_set_timer_cb
and it should work for TLS as well. It is mandatory for DTLS, but not for TLS so that's probably the reason why it is like this.
c701254
to
565abe0
Compare
The previous implementation of monitoring DTLS peers' activity relied on the absolute system time to track the last activity timestamp. However, this approach had the unintended consequence of being affected by changes in the system time. For instance, modifying the system time by an interval equivalent to the DTLS inactivity timeout would trigger a false inactivity timeout and result in the closure of the DTLS session. To address this issue, the monitoring mechanism has been updated to utilize a monotonic timer. This timer is independent of system time changes and provides a more accurate measure of the duration of inactivity. By using a monotonic timer, the DTLS session will only be closed if no activity occurs within the specified timeout period, regardless of any changes in the system time. This refactor improves the reliability and accuracy of DTLS peer monitoring, ensuring that the DTLS sessions are closed based on actual inactivity rather than being influenced by system time adjustments.
565abe0
to
469ea8f
Compare
SonarCloud Quality Gate failed. |
No description provided.