Skip to content

Commit fb2a966

Browse files
plskeggsnashif
authored andcommitted
net: sockets: tls: use cipherlist set by user
The function setsockopt() option TLS_CIPHERSUITE_LIST allows the user to set a specific list of ciphersuites when using the Zephyr native + Mbed TLS stack. However, the list provided was not actually being used later for handshaking. This adds the missing calls to mbedtls_ssl_conf_ciphersuites() to use the list provided. If none was provided, fall back to the default list as determined by Mbed TLS from Kconfig values. Signed-off-by: Pete Skeggs <[email protected]>
1 parent 307a60e commit fb2a966

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

subsys/net/lib/sockets/sockets_tls.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,13 @@ static int tls_mbedtls_init(struct tls_context *context, bool is_server)
10761076
return ret;
10771077
}
10781078

1079+
if (context->options.ciphersuites[0] != 0) {
1080+
/* Specific ciphersuites configured, so use them */
1081+
NET_DBG("Using user-specified ciphersuites");
1082+
mbedtls_ssl_conf_ciphersuites(&context->config,
1083+
context->options.ciphersuites);
1084+
}
1085+
10791086
#if defined(CONFIG_MBEDTLS_SSL_ALPN)
10801087
if (ALPN_MAX_PROTOCOLS && context->options.alpn_list[0] != NULL) {
10811088
ret = mbedtls_ssl_conf_alpn_protocols(&context->config,
@@ -1198,6 +1205,8 @@ static int tls_opt_ciphersuite_list_set(struct tls_context *context,
11981205
memcpy(context->options.ciphersuites, optval, optlen);
11991206
context->options.ciphersuites[cipher_cnt] = 0;
12001207

1208+
mbedtls_ssl_conf_ciphersuites(&context->config,
1209+
context->options.ciphersuites);
12011210
return 0;
12021211
}
12031212

0 commit comments

Comments
 (0)