Просмотр исходного кода

esp_http_client: Support client key password for HTTPS connections.

Closes https://github.com/espressif/esp-idf/pull/7420
Closes https://github.com/espressif/esp-idf/issues/7418

Signed-off-by: Aditya Patwardhan <aditya.patwardhan@espressif.com>
Jon Maloney 4 лет назад
Родитель
Сommit
c8b7f7a5d3

+ 4 - 0
components/esp_http_client/esp_http_client.c

@@ -632,6 +632,10 @@ esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *co
         }
     }
 
+    if (config->client_key_password && config->client_key_password_len > 0) {
+        esp_transport_ssl_set_client_key_password(ssl, config->client_key_password, config->client_key_password_len);
+    }
+
     if (config->skip_cert_common_name_check) {
         esp_transport_ssl_skip_common_name_check(ssl);
     }

+ 2 - 0
components/esp_http_client/include/esp_http_client.h

@@ -113,6 +113,8 @@ typedef struct {
     size_t                      client_cert_len;     /*!< Length of the buffer pointed to by client_cert_pem. May be 0 for null-terminated pem */
     const char                  *client_key_pem;     /*!< SSL client key, PEM format as string, if the server requires to verify client */
     size_t                      client_key_len;      /*!< Length of the buffer pointed to by client_key_pem. May be 0 for null-terminated pem */
+    const char                  *client_key_password;      /*!< Client key decryption password string */
+    size_t                      client_key_password_len;   /*!< String length of the password pointed to by client_key_password */
     const char                  *user_agent;         /*!< The User Agent string to send with HTTP requests */
     esp_http_client_method_t    method;                   /*!< HTTP Method */
     int                         timeout_ms;               /*!< Network timeout in milliseconds */