net/sock/dtls: allow using multiple credentials#16179
net/sock/dtls: allow using multiple credentials#16179PeterKietzmann merged 10 commits intoRIOT-OS:masterfrom
Conversation
d47f275 to
198c519
Compare
198c519 to
aaecc9c
Compare
|
@janosbrodbeck the new definitions are not split into their own header, this should avoid the issues when using Sock Async. |
There was a problem hiding this comment.
It works now with async sockets!
tests/pkg_tinydtls_sock_async/dtls-server.c needs one change, because the PSK matching changed. The server in the test does not provide an identity for the credential. Don't know why the ID is missing but now it leads with the current changes to not being able to find a matching credential, since it compares with an empty identity.
static const uint8_t psk_id_0[] = PSK_DEFAULT_IDENTITY; needs to be added to pkg_tinydtls_sock_async/dtls-server.c. And the ID then needs to be added to the credential.
|
Looks good to me. Existing code is still working (except the test, but I'll leave that out) and the API is easy to use. Already have a WIP build for my gcoap-dtls running which supports the new functionality. However, I am for a small extension in When creating a new DTLS socket it is mandatory to provide a credman tag, as it includes But the current API does not provide that functionality. It should be fairly easy to achieve, since |
Added in 26cf8cf.
Added in b051dae. |
pokgak
left a comment
There was a problem hiding this comment.
Almost done. Just need to update the docs.
sys/include/net/sock/dtls.h
Outdated
| * registering a callback with @ref sock_dtls_set_client_psk_cb. If no callback is registered the | ||
| * credential is chosen as follows: if a hint is sent by the server, all credentials registered to | ||
| * the sock are checked for a matching @ref psk_params_t::hint "hint". A credential is select on | ||
| * matching hint. If no credential matches the hint or no hint is provided, the first PSK credential |
There was a problem hiding this comment.
Not sure what exactly needs to change here. I made some adaptions to the doc in 74ea508. Could you take a look?
There was a problem hiding this comment.
Besides the documentation updates that pokgak suggested, I am very happy.
Tested it again with examples/dtls-sock, tests/pkg_tinydtls_sock_async and my gcoap-dtls PR without adaption changes and with some first integration changes. The right credentials are used, and existing single credential use cases are also working without changes.
|
I added another function to get a read-only array of the registered credentials on a sock. |
6187e42 to
1f6e68c
Compare
|
Any maintainer that would like to take a look? @miri64? @cgundogan? |
|
@leandrolanzieri thanks, looks better! Maybe introduce PSK and RPK as abbreviations. Mention that the hint (string) could also be changed, you could also explain that it is printed on the client (for verification by the user). I leave this up to you... Please squash directly |
4a153ea to
f2dda22
Compare
Added the suggestions and squashed directly! |
f2dda22 to
a5ccb9a
Compare
PeterKietzmann
left a comment
There was a problem hiding this comment.
ACK from my side. Anyone else who wants to give this PR a look before merge?
a5ccb9a to
835589a
Compare
|
Well then, go! |
Contribution description
Currently only one credential can be associated to each DTLS sock. This limits certain use cases that need to establish multiple connections on a single sock using potentially multiple credentials.
This PR proposes an extension of the sock DTLS API to allow registering multiple credentials to be used on a single sock. An application may register callbacks to specify a certain credential from the list based on the session information (and, when using PSK, based on the hint that may have been sent).
Additionally, now a server can send a PSK Identity hint to a client during the handshake, to help deciding on the PSK Identity that should be used.
Finally, the example application has been extended to show these functionalities.
Testing procedure
Issues/PRs references
None so far