fix(esp_wifi): Code cleanup for PR#15550 PR#15551

Closes https://github.com/espressif/esp-idf/pull/15550
Closes https://github.com/espressif/esp-idf/pull/15551
This commit is contained in:
Kapil Gupta
2025-03-11 12:29:36 +05:30
parent 4470cf7b49
commit c2fad24731
8 changed files with 92 additions and 81 deletions

View File

@@ -100,15 +100,18 @@ menu "Example Configuration"
help
Use default CA certificate bundle for WiFi enterprise connection
config EXAMPLE_USE_SERVER_DOMAIN_MATCH
bool "Validate server cert domain"
config EXAMPLE_VALIDATE_SERVER_CERT_DOMAIN
bool "Enable server certificate domain validation"
depends on EXAMPLE_VALIDATE_SERVER_CERT
default n
help
Validate the certificate domain
Enable validation of the server certificate's domain name.
config EXAMPLE_SERVER_DOMAIN_MATCH_VALUE
string "Server cert domain"
depends on EXAMPLE_USE_SERVER_DOMAIN_MATCH
config EXAMPLE_SERVER_CERT_DOMAIN
string "Expected server certificate domain"
depends on EXAMPLE_VALIDATE_SERVER_CERT_DOMAIN
default "espressif.com"
help
Accept only server certificates matching this domain
Specify the expected domain name for the server certificate.
The connection will be accepted only if the server certificate matches this domain.
endmenu

View File

@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: 2006-2016 ARM Limited
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -33,6 +33,7 @@
#define EXAMPLE_EAP_ID CONFIG_EXAMPLE_EAP_ID
#define EXAMPLE_EAP_USERNAME CONFIG_EXAMPLE_EAP_USERNAME
#define EXAMPLE_EAP_PASSWORD CONFIG_EXAMPLE_EAP_PASSWORD
#define EXAMPLE_SERVER_CERT_DOMAIN CONFIG_EXAMPLE_SERVER_CERT_DOMAIN
/* FreeRTOS event group to signal when we are connected & ready to make a request */
static EventGroupHandle_t wifi_event_group;
@@ -156,8 +157,8 @@ static void initialise_wifi(void)
#ifdef CONFIG_EXAMPLE_USE_DEFAULT_CERT_BUNDLE
ESP_ERROR_CHECK(esp_eap_client_use_default_cert_bundle(true));
#endif
#ifdef CONFIG_EXAMPLE_USE_SERVER_DOMAIN_MATCH
ESP_ERROR_CHECK(esp_eap_client_set_domain_match(CONFIG_EXAMPLE_SERVER_DOMAIN_MATCH_VALUE));
#ifdef CONFIG_EXAMPLE_VALIDATE_SERVER_CERT_DOMAIN
ESP_ERROR_CHECK(esp_eap_client_set_domain_name(EXAMPLE_SERVER_CERT_DOMAIN));
#endif
ESP_ERROR_CHECK(esp_wifi_sta_enterprise_enable());
ESP_ERROR_CHECK(esp_wifi_start());