From df5a25aa404582fa91b42ceccb42a468737152ae Mon Sep 17 00:00:00 2001 From: Akos Vandra Date: Mon, 7 Nov 2022 15:27:00 +0100 Subject: [PATCH 1/3] allow https server to accept and pass thru alpn protocols to the underlying esp-tls server --- components/esp_https_server/include/esp_https_server.h | 2 ++ components/esp_https_server/src/https_server.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/components/esp_https_server/include/esp_https_server.h b/components/esp_https_server/include/esp_https_server.h index 071d5b5ff4d..45cfa176d13 100644 --- a/components/esp_https_server/include/esp_https_server.h +++ b/components/esp_https_server/include/esp_https_server.h @@ -99,6 +99,8 @@ struct httpd_ssl_config { void *ssl_userdata; /*!< user data to add to the ssl context */ esp_tls_handshake_callback cert_select_cb; /*!< Certificate selection callback to use */ + + const char** alpn_protos; /*!< Application protocols the server supports in order of prefernece. Used for negotiating during the TLS handshake, first one the client supports is selected. The data structure must live as long as the https server itself! */ }; typedef struct httpd_ssl_config httpd_ssl_config_t; diff --git a/components/esp_https_server/src/https_server.c b/components/esp_https_server/src/https_server.c index f77c775ea37..ea810e77b06 100644 --- a/components/esp_https_server/src/https_server.c +++ b/components/esp_https_server/src/https_server.c @@ -212,6 +212,9 @@ static httpd_ssl_ctx_t *create_secure_context(const struct httpd_ssl_config *con cfg->userdata = config->ssl_userdata; + + cfg->alpn_protos = config->alpn_protos; + #if defined(CONFIG_ESP_TLS_SERVER_CERT_SELECT_HOOK) cfg->cert_select_cb = config->cert_select_cb; #endif From b60a9e667809846011605286c2c308a1a4a316dd Mon Sep 17 00:00:00 2001 From: Akos Vandra Date: Wed, 9 Nov 2022 07:55:26 +0100 Subject: [PATCH 2/3] add alpn initializer in esp https server default --- components/esp_https_server/include/esp_https_server.h | 1 + 1 file changed, 1 insertion(+) diff --git a/components/esp_https_server/include/esp_https_server.h b/components/esp_https_server/include/esp_https_server.h index 45cfa176d13..330f2e646b6 100644 --- a/components/esp_https_server/include/esp_https_server.h +++ b/components/esp_https_server/include/esp_https_server.h @@ -152,6 +152,7 @@ typedef struct httpd_ssl_config httpd_ssl_config_t; .user_cb = NULL, \ .ssl_userdata = NULL, \ .cert_select_cb = NULL \ + .alpn_protos = NULL \ } /** From 322301238fb6a04e5d80bd659ea535de595fe49c Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Wed, 9 Nov 2022 15:11:22 +0530 Subject: [PATCH 3/3] esp_https_server: fix build failure due to syntax error --- components/esp_https_server/include/esp_https_server.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp_https_server/include/esp_https_server.h b/components/esp_https_server/include/esp_https_server.h index 330f2e646b6..bffdfce62ba 100644 --- a/components/esp_https_server/include/esp_https_server.h +++ b/components/esp_https_server/include/esp_https_server.h @@ -151,8 +151,8 @@ typedef struct httpd_ssl_config httpd_ssl_config_t; .use_secure_element = false, \ .user_cb = NULL, \ .ssl_userdata = NULL, \ - .cert_select_cb = NULL \ - .alpn_protos = NULL \ + .cert_select_cb = NULL, \ + .alpn_protos = NULL, \ } /**