Skip to content
This repository was archived by the owner on Jul 31, 2024. It is now read-only.

Commit 84413b0

Browse files
committed
dtls: Support DTLS 1.2 Connection IDs
Add a new Kconfig option for using DTLS 1.2 Connection IDs. Set the connection ID socket option when the connection ID Kconfig option is set. Signed-off-by: Sam Friedman <[email protected]>
1 parent 7f828df commit 84413b0

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

net/golioth/Kconfig

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ module = GOLIOTH
2727
module-str = golioth
2828
source "subsys/logging/Kconfig.template.log_config"
2929

30+
config GOLIOTH_USE_CONNECTION_ID
31+
bool "Use DTLS 1.2 Connection IDs"
32+
select MBEDTLS_SSL_DTLS_CONNECTION_ID
33+
help
34+
Use DTLS 1.2 Connection IDs. Connection IDs replace IP
35+
addresses as the session identifier, and can be used to
36+
reduce the number of handshakes a device has to make in
37+
certain scenarios.
38+
3039
choice GOLIOTH_AUTH_METHOD
3140
prompt "Authentication method support"
3241

net/golioth/golioth.c

+12
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ static int golioth_setsockopt_dtls(struct golioth_client *client, int sock,
9090
}
9191
}
9292

93+
/* If Connection IDs are enabled, set socket option to send CIDs, but not require that the
94+
* server sends one in return.
95+
*/
96+
#ifdef CONFIG_GOLIOTH_USE_CONNECTION_ID
97+
int enabled = 1;
98+
99+
ret = zsock_setsockopt(sock, SOL_TLS, TLS_DTLS_CID, &enabled, sizeof(enabled));
100+
if (ret < 0) {
101+
return -errno;
102+
}
103+
#endif /* CONFIG_GOLIOTH_USE_CONNECTION_ID */
104+
93105
return 0;
94106
}
95107

samples/hello/sample.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ tests:
5656
- CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y
5757
- CONFIG_MBEDTLS_CIPHER_MODE_CBC_ENABLED=n
5858
- CONFIG_GOLIOTH_CIPHERSUITES="TLS_PSK_WITH_AES_128_CCM_8"
59+
sample.golioth.hello.psk.fast.cid:
60+
platform_allow: >
61+
esp32_devkitc_wroom
62+
mimxrt1060_evkb
63+
nrf52840dk_nrf52840
64+
qemu_x86
65+
extra_configs:
66+
- CONFIG_GOLIOTH_USE_CONNECTION_ID=y
67+
sample.golioth.hello.psk.long_start.cid:
68+
platform_allow: nrf9160dk_nrf9160_ns
69+
timeout: 120
70+
extra_configs:
71+
- CONFIG_GOLIOTH_USE_CONNECTION_ID=y
5972
sample.golioth.hello.psk.long_start:
6073
platform_allow: nrf9160dk_nrf9160_ns
6174
timeout: 120

0 commit comments

Comments
 (0)