From 8b72dc9fb063d770623508bd4bd7f2a7dd192729 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Anders=20Kal=C3=B8r?= Date: Sat, 10 Nov 2018 23:51:05 +0100 Subject: [PATCH] esp_http_client: Add support for mutual authentication Closes https://github.com/espressif/esp-idf/pull/2688 --- components/esp_http_client/esp_http_client.c | 8 ++++++++ components/esp_http_client/include/esp_http_client.h | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index c7a613bca9..6e55c9bf49 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -490,6 +490,14 @@ esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *co if (config->cert_pem) { esp_transport_ssl_set_cert_data(ssl, config->cert_pem, strlen(config->cert_pem)); } + + if (config->client_cert_pem) { + esp_transport_ssl_set_client_cert_data(ssl, config->client_cert_pem, strlen(config->client_cert_pem)); + } + + if (config->client_key_pem) { + esp_transport_ssl_set_client_key_data(ssl, config->client_key_pem, strlen(config->client_key_pem)); + } #endif if (_set_config(client, config) != ESP_OK) { diff --git a/components/esp_http_client/include/esp_http_client.h b/components/esp_http_client/include/esp_http_client.h index 4e940a6d10..77e9d85208 100644 --- a/components/esp_http_client/include/esp_http_client.h +++ b/components/esp_http_client/include/esp_http_client.h @@ -105,7 +105,9 @@ typedef struct { esp_http_client_auth_type_t auth_type; /*!< Http authentication type, see `esp_http_client_auth_type_t` */ const char *path; /*!< HTTP Path, if not set, default is `/` */ const char *query; /*!< HTTP query */ - const char *cert_pem; /*!< SSL Certification, PEM format as string, if the client requires to verify server */ + const char *cert_pem; /*!< SSL server certification, PEM format as string, if the client requires to verify server */ + const char *client_cert_pem; /*!< SSL client certification, PEM format as string, if the server requires to verify client */ + const char *client_key_pem; /*!< SSL client key, PEM format as string, if the server requires to verify client */ esp_http_client_method_t method; /*!< HTTP Method */ int timeout_ms; /*!< Network timeout in milliseconds */ bool disable_auto_redirect; /*!< Disable HTTP automatic redirects */ -- 2.40.0