diff --git a/pkg/tinydtls/contrib/sock_dtls.c b/pkg/tinydtls/contrib/sock_dtls.c index 7c537370c7..4b8611c115 100644 --- a/pkg/tinydtls/contrib/sock_dtls.c +++ b/pkg/tinydtls/contrib/sock_dtls.c @@ -561,7 +561,11 @@ int sock_dtls_session_init(sock_dtls_t *sock, const sock_udp_ep_t *ep, void sock_dtls_session_destroy(sock_dtls_t *sock, sock_dtls_session_t *remote) { - dtls_close(sock->dtls_ctx, &remote->dtls_session); + dtls_peer_t *peer = dtls_get_peer(sock->dtls_ctx, &remote->dtls_session); + if (peer) { + /* dtls_reset_peer() also sends close_notify if not already sent */ + dtls_reset_peer(sock->dtls_ctx, peer); + } } void sock_dtls_session_get_udp_ep(const sock_dtls_session_t *session, diff --git a/sys/include/net/sock/dtls.h b/sys/include/net/sock/dtls.h index 55a1377229..61d1b03660 100644 --- a/sys/include/net/sock/dtls.h +++ b/sys/include/net/sock/dtls.h @@ -702,6 +702,11 @@ int sock_dtls_session_init(sock_dtls_t *sock, const sock_udp_ep_t *ep, * * @param[in] sock @ref sock_dtls_t, which the session is created on * @param[in] remote Remote session to destroy + * + * @note For tinyDTLS this function destroys the session object right after notifying the remote + * peer about the closing. This is an interim solution, preventing endlessly blocked session + * slots, but allows as a consequence truncation attacks. + * More details in the [issue](https://github.com/eclipse/tinydtls/issues/95). */ void sock_dtls_session_destroy(sock_dtls_t *sock, sock_dtls_session_t *remote);