Implement server session ticket support with mbedtls

Closes https://github.com/espressif/esp-idf/pull/7048

Signed-off-by: Aditya Patwardhan <aditya.patwardhan@espressif.com>
This commit is contained in:
Daniel Bahrdt
2021-05-19 17:16:59 +02:00
committed by Aditya Patwardhan
parent 8f283421da
commit 7e886ca9ed
8 changed files with 207 additions and 12 deletions

View File

@@ -63,6 +63,9 @@ struct httpd_ssl_config {
/** Port used when transport mode is insecure (default 80) */
uint16_t port_insecure;
/** Enable tls session tickets */
bool session_tickets;
};
typedef struct httpd_ssl_config httpd_ssl_config_t;
@@ -109,6 +112,7 @@ typedef struct httpd_ssl_config httpd_ssl_config_t;
.transport_mode = HTTPD_SSL_TRANSPORT_SECURE, \
.port_secure = 443, \
.port_insecure = 80, \
.session_tickets = false, \
}
/**

View File

@@ -145,6 +145,7 @@ static void free_secure_context(void *ctx)
if (cfg->serverkey_buf) {
free((void *)cfg->serverkey_buf);
}
esp_tls_cfg_server_session_tickets_free(cfg);
free(cfg);
free(ssl_ctx);
}
@@ -160,6 +161,16 @@ static httpd_ssl_ctx_t *create_secure_context(const struct httpd_ssl_config *con
free(ssl_ctx);
return NULL;
}
if (config->session_tickets) {
if ( esp_tls_cfg_server_session_tickets_init(cfg) != ESP_OK ) {
ESP_LOGE(TAG, "Failed to init session ticket support");
free(ssl_ctx);
free(cfg);
return NULL;
}
}
ssl_ctx->tls_cfg = cfg;
/* 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) {