mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 12:10:59 +00:00
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:
@@ -15,6 +15,7 @@ const static char *TAG = "esp_https_server";
|
||||
typedef struct httpd_ssl_ctx {
|
||||
esp_tls_cfg_server_t *tls_cfg;
|
||||
httpd_open_func_t open_fn;
|
||||
esp_https_server_user_cb *user_cb;
|
||||
} httpd_ssl_ctx_t;
|
||||
|
||||
/**
|
||||
@@ -119,6 +120,13 @@ static esp_err_t httpd_ssl_open(httpd_handle_t server, int sockfd)
|
||||
if (global_ctx->open_fn) {
|
||||
(global_ctx->open_fn)(server, sockfd);
|
||||
}
|
||||
|
||||
if (global_ctx->user_cb) {
|
||||
esp_https_server_user_cb_arg_t user_cb_data = {0};
|
||||
user_cb_data.tls = tls;
|
||||
(global_ctx->user_cb)((void *)&user_cb_data);
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
fail:
|
||||
esp_tls_server_session_delete(tls);
|
||||
@@ -172,6 +180,7 @@ static httpd_ssl_ctx_t *create_secure_context(const struct httpd_ssl_config *con
|
||||
}
|
||||
|
||||
ssl_ctx->tls_cfg = cfg;
|
||||
ssl_ctx->user_cb = config->user_cb;
|
||||
/* cacert = CA which signs client cert, or client cert itself , which is mapped to client_verify_cert_pem */
|
||||
if(config->client_verify_cert_pem != NULL) {
|
||||
cfg->cacert_buf = (unsigned char *)malloc(config->client_verify_cert_len);
|
||||
|
Reference in New Issue
Block a user