feature: Added user callback for esp_https_server

- Can be used to get connection or client information (SSL context)
- E.g. Client certificate, Socket FD, Connection state, etc.
- Added example callback for getting client certificate information in 'https_server/simple' example

Closes https://github.com/espressif/esp-idf/issues/7479
This commit is contained in:
Laukik Hase
2021-10-08 14:19:57 +05:30
parent 8c3287e0db
commit 1d2b2b5879
8 changed files with 157 additions and 17 deletions

View File

@@ -10,6 +10,7 @@
#include <stdbool.h>
#include "esp_err.h"
#include "esp_http_server.h"
#include "esp_tls.h"
#ifdef __cplusplus
extern "C" {
@@ -20,6 +21,22 @@ typedef enum {
HTTPD_SSL_TRANSPORT_INSECURE // SSL disabled
} httpd_ssl_transport_mode_t;
/**
* @brief Callback data struct, contains the ESP-TLS connection handle
*/
typedef struct esp_https_server_user_cb_arg {
const esp_tls_t *tls;
} esp_https_server_user_cb_arg_t;
/**
* @brief Callback function prototype
* Can be used to get connection or client information (SSL context)
* E.g. Client certificate, Socket FD, Connection state, etc.
*
* @param user_cb Callback data struct
*/
typedef void esp_https_server_user_cb(esp_https_server_user_cb_arg_t *user_cb);
/**
* HTTPS server config struct
*
@@ -66,6 +83,9 @@ struct httpd_ssl_config {
/** Enable tls session tickets */
bool session_tickets;
/** User callback for esp_https_server */
esp_https_server_user_cb *user_cb;
};
typedef struct httpd_ssl_config httpd_ssl_config_t;
@@ -113,6 +133,7 @@ typedef struct httpd_ssl_config httpd_ssl_config_t;
.port_secure = 443, \
.port_insecure = 80, \
.session_tickets = false, \
.user_cb = NULL, \
}
/**