forked from espressif/esp-idf
MQTT: add server side authentication to mutual auth example
This commit is contained in:
@@ -11,3 +11,4 @@ project(mqtt_ssl_mutual_auth)
|
|||||||
|
|
||||||
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "main/client.crt" TEXT)
|
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "main/client.crt" TEXT)
|
||||||
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "main/client.key" TEXT)
|
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "main/client.key" TEXT)
|
||||||
|
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "main/mosquitto.org.crt" TEXT)
|
||||||
|
@@ -38,6 +38,8 @@ Paste the generated CSR in the [Mosquitto test certificate signer](https://test.
|
|||||||
|
|
||||||
Please note, that the supplied files `client.crt` and `client.key` in the `main` directory are only placeholders for your client certificate and key (i.e. the example "as is" would compile but would not connect to the broker)
|
Please note, that the supplied files `client.crt` and `client.key` in the `main` directory are only placeholders for your client certificate and key (i.e. the example "as is" would compile but would not connect to the broker)
|
||||||
|
|
||||||
|
The server certificate `mosquitto.org.crt` can be downloaded in pem format from [mosquitto.org.crt](https://test.mosquitto.org/ssl/mosquitto.org.crt).
|
||||||
|
|
||||||
### Build and Flash
|
### Build and Flash
|
||||||
|
|
||||||
Build the project and flash it to the board, then run monitor tool to view serial output:
|
Build the project and flash it to the board, then run monitor tool to view serial output:
|
||||||
|
@@ -35,6 +35,8 @@ extern const uint8_t client_cert_pem_start[] asm("_binary_client_crt_start");
|
|||||||
extern const uint8_t client_cert_pem_end[] asm("_binary_client_crt_end");
|
extern const uint8_t client_cert_pem_end[] asm("_binary_client_crt_end");
|
||||||
extern const uint8_t client_key_pem_start[] asm("_binary_client_key_start");
|
extern const uint8_t client_key_pem_start[] asm("_binary_client_key_start");
|
||||||
extern const uint8_t client_key_pem_end[] asm("_binary_client_key_end");
|
extern const uint8_t client_key_pem_end[] asm("_binary_client_key_end");
|
||||||
|
extern const uint8_t server_cert_pem_start[] asm("_binary_mosquitto_org_crt_start");
|
||||||
|
extern const uint8_t server_cert_pem_end[] asm("_binary_mosquitto_org_crt_end");
|
||||||
|
|
||||||
static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event)
|
static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event)
|
||||||
{
|
{
|
||||||
@@ -90,6 +92,7 @@ static void mqtt_app_start(void)
|
|||||||
.event_handle = mqtt_event_handler,
|
.event_handle = mqtt_event_handler,
|
||||||
.client_cert_pem = (const char *)client_cert_pem_start,
|
.client_cert_pem = (const char *)client_cert_pem_start,
|
||||||
.client_key_pem = (const char *)client_key_pem_start,
|
.client_key_pem = (const char *)client_key_pem_start,
|
||||||
|
.cert_pem = (const char *)server_cert_pem_start,
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
|
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
|
||||||
|
@@ -1 +1 @@
|
|||||||
COMPONENT_EMBED_TXTFILES := client.crt client.key
|
COMPONENT_EMBED_TXTFILES := client.crt client.key mosquitto.org.crt
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIEAzCCAuugAwIBAgIUBY1hlCGvdj4NhBXkZ/uLUZNILAwwDQYJKoZIhvcNAQEL
|
||||||
|
BQAwgZAxCzAJBgNVBAYTAkdCMRcwFQYDVQQIDA5Vbml0ZWQgS2luZ2RvbTEOMAwG
|
||||||
|
A1UEBwwFRGVyYnkxEjAQBgNVBAoMCU1vc3F1aXR0bzELMAkGA1UECwwCQ0ExFjAU
|
||||||
|
BgNVBAMMDW1vc3F1aXR0by5vcmcxHzAdBgkqhkiG9w0BCQEWEHJvZ2VyQGF0Y2hv
|
||||||
|
by5vcmcwHhcNMjAwNjA5MTEwNjM5WhcNMzAwNjA3MTEwNjM5WjCBkDELMAkGA1UE
|
||||||
|
BhMCR0IxF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Iwimx839
|
||||||
|
LdUdRudafMu5T5Xma182OC0/u/xRlEm+tvKGGmfFcN0piqVl8OrSPBgIlb+1IKJE
|
||||||
|
m/XriWr/Cq4h/JfB7NTsezVslgkBaoU=
|
||||||
|
-----END CERTIFICATE-----
|
Reference in New Issue
Block a user