mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-13 04:42:01 +03:00
feat(esp_tls): supports setting tls version and ciphersuite in server config
Closes https://github.com/espressif/esp-idf/issues/17660
This commit is contained in:
@@ -21,6 +21,10 @@
|
||||
#include "esp_tls.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_EXAMPLE_ENABLE_HTTPS_SERVER_CUSTOM_CIPHERSUITES
|
||||
#include "mbedtls/ssl_ciphersuites.h"
|
||||
#endif // CONFIG_EXAMPLE_ENABLE_HTTPS_SERVER_CUSTOM_CIPHERSUITES
|
||||
|
||||
/* A simple example that demonstrates how to create GET and POST
|
||||
* handlers and start an HTTPS server.
|
||||
*/
|
||||
@@ -159,6 +163,27 @@ static httpd_handle_t start_webserver(void)
|
||||
conf.prvtkey_pem = prvtkey_pem_start;
|
||||
conf.prvtkey_len = prvtkey_pem_end - prvtkey_pem_start;
|
||||
|
||||
#if CONFIG_EXAMPLE_ENABLE_HTTPS_SERVER_CUSTOM_CIPHERSUITES
|
||||
static const int ciphersuites_to_use[] = {
|
||||
MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
|
||||
MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,
|
||||
MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
|
||||
MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
|
||||
0,
|
||||
};
|
||||
conf.ciphersuites_list = ciphersuites_to_use;
|
||||
#else
|
||||
conf.ciphersuites_list = NULL;
|
||||
#endif // CONFIG_EXAMPLE_ENABLE_HTTPS_SERVER_CUSTOM_CIPHERSUITES
|
||||
|
||||
#if CONFIG_EXAMPLE_ENABLE_HTTPS_SERVER_TLS_1_3_ONLY
|
||||
conf.tls_version = ESP_TLS_VER_TLS_1_3;
|
||||
#elif CONFIG_EXAMPLE_ENABLE_HTTPS_SERVER_TLS_1_2_ONLY
|
||||
conf.tls_version = ESP_TLS_VER_TLS_1_2;
|
||||
#else
|
||||
conf.tls_version = ESP_TLS_VER_ANY;
|
||||
#endif // CONFIG_EXAMPLE_ENABLE_HTTPS_SERVER_TLS_1_3_ONLY
|
||||
|
||||
#if CONFIG_EXAMPLE_ENABLE_HTTPS_USER_CALLBACK
|
||||
conf.user_cb = https_server_user_callback;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user