securitysslnetwork-programmingdtlscoap

Does DTLS require sessions to timeout?


I'm trying to figure out the most data-use efficient way to secure our CoAP API. DTLS seems to be the right way to do it, but looking at how much data the handshake requires (and making some uninformed assumptions about how often that needs to happen) it seems that DTLS with X.509 certificates dwarfs the actual data use of CoAP itself.

The most obvious solution would be to just use symmetric keys that are programmed in at the factory, but I don't think I like the security risks that imposes. As far as I understand there is no way to recover from a server-side intrusion other than manually installing new keys on all the devices.

The solution that I'm thinking of proposing is basically a hybrid of the two, distribute the devices with a secured CA that lets the devices do a standard handshake and establish a "temporary" symmetric key. Then to save bandwidth to the device I'd store that key (session?) in a database for the device to continue for months or years at a time, but still have the ability to expire the keys if we discover any have gotten out.

I know I could just use the standard session resumption handshake to resume a session, but I'm not sure that is required since DTLS is connection-less and I can pretend the "connection" is always open. And if I can avoid having to repeat the handshake that would lower data consumption and probably lower server load somewhat too.

The things that I don't know are: Does DTLS define a limit on how long a session can remain open? Or is there a timeout where a session must be removed after some period of inactivity? If not, do the implementations of DTLS define one themselves?

Is there any thing else that I may be overlooking as to why this wouldn't work? Or is there something more straightforward that I'm not thinking of?


Solution

  • Timeouts are application specific, and you can set them as high as you need, or just keep the connections around as long as you can (eg. with a fixed number of usable connections, timing out the least recently used when a new one is opened).

    Session resumption data can be held for as long as both parties agree the resumption data is still good (eg. no underlying certificates have expired). Session resumption should be at least as cheap as manually installed symmetric keys.

    So a sensible approach seems to be to just try continuing the session if the sending party still has it open, fall back to session resumption on error, and if that doesn't work go through the full handshake again. There don't necessarily need to be agreed-on times for any of that.