I have been searching the internet for how to make a secure connection with a mqtt broker like mosquitto or aws IoT. It seems that for aws I would only need to download the three certificates needed and use them as my cert_pem, client_cert_pem and client_key_pem constants.
The questions are:
How do I get this certificates to use mosquitto or another free mqtt broker?
The mbed ssl and wss examples seem to only use the cert_pem certificate, can I just define the other two certificates client_cert_pem and client_key_pem and both mbed and wss examples would work?
Something like this would work in the app_main.c?
Code: Select all
static void mqtt_app_start(void)
{
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.cert_pem = (const char *)mqtt_cert_pem_start,
.client_cert_pem = (const char *)mqtt_client_cert_pem_start,
.client_key_pem = (const char *)mqtt_client_key_pem_start,
};
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
/* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */
esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL);
esp_mqtt_client_start(client);
}