Skip to content

Commit 00cc9db

Browse files
danghbglmfe
authored andcommitted
feat(mqtt): enable custom TLS cipher suites for MQTTs
- Add `ciphersuites_list` to `esp_mqtt_client_config_t` for specifying TLS cipher suites. - Update SSL transport configuration to use the provided cipher suites. - Users are responsible for managing the cipher suites list memory.
1 parent 6af4446 commit 00cc9db

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

include/mqtt_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ typedef struct esp_mqtt_client_config_t {
274274
If NULL, server certificate CN must match hostname.
275275
This is ignored if skip_cert_common_name_check=true.
276276
It's not copied nor freed by the client, user needs to clean up.*/
277+
const int *ciphersuites_list; /*!< Pointer to a zero-terminated array of IANA identifiers of TLS cipher suites.
278+
Please ensure the validity of the list, and note that it is not copied or freed by the client. */
277279
} verification; /*!< Security verification of the broker */
278280
} broker; /*!< Broker address and security verification */
279281
/**

lib/include/mqtt_client_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ typedef struct {
8585
int clientkey_password_len;
8686
bool use_global_ca_store;
8787
esp_err_t ((*crt_bundle_attach)(void *conf));
88+
const int *ciphersuites_list;
8889
const char *cacert_buf;
8990
size_t cacert_bytes;
9091
const char *clientcert_buf;

mqtt_client.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ static esp_err_t esp_mqtt_set_ssl_transport_properties(esp_transport_list_handle
158158
goto esp_mqtt_set_transport_failed);
159159

160160
}
161+
162+
if(cfg->ciphersuites_list)
163+
{
164+
esp_transport_ssl_set_ciphersuites_list(ssl,cfg->ciphersuites_list);
165+
}
166+
161167
if (cfg->psk_hint_key) {
162168
#if defined(MQTT_SUPPORTED_FEATURE_PSK_AUTHENTICATION) && MQTT_ENABLE_SSL
163169
#ifdef CONFIG_ESP_TLS_PSK_VERIFICATION
@@ -578,6 +584,7 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
578584
client->config->cacert_bytes = config->broker.verification.certificate_len;
579585
client->config->psk_hint_key = config->broker.verification.psk_hint_key;
580586
client->config->crt_bundle_attach = config->broker.verification.crt_bundle_attach;
587+
client->config->ciphersuites_list = config->broker.verification.ciphersuites_list;
581588
client->config->clientcert_buf = config->credentials.authentication.certificate;
582589
client->config->clientcert_bytes = config->credentials.authentication.certificate_len;
583590
client->config->clientkey_buf = config->credentials.authentication.key;

0 commit comments

Comments
 (0)