8000 Fix for the missing certificated in WPA2 Enterprise connection (#263) · pycom/pycom-micropython-sigfox@68c0063 · GitHub
[go: up one dir, main page]

Skip to content
8000
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 68c0063

Browse files
VladPetroviciVladP
authored andcommitted
Fix for the missing certificated in WPA2 Enterprise connection (#263)
* Fix for the missing certificated in WPA2 Enterprise connection * Added verification check for the certificate content, updated comment Co-authored-by: VladP <vlad.XT@pycom.io>
1 parent b596cea commit 68c0063

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

esp32/mods/modwlan.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,28 @@ STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_aut
760760
goto os_error;
761761
}
762762

763+
/* Read certificates content (if they are available) for the WPA2 Enterprise authentication */
764+
if (auth == WIFI_AUTH_WPA2_ENTERPRISE) {
765+
const char *wpa_cert = NULL;
766+
if (wlan_wpa2_ent.ca_certs_path != NULL) {
767+
wpa_cert = pycom_util_read_file(wlan_wpa2_ent.ca_certs_path, &wlan_obj.vstr_ca);
768+
if(wpa_cert == NULL) {
769+
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "certificate file not found"));
770+
}
771+
}
772+
773+
if (wlan_wpa2_ent.client_key_path != NULL && wlan_wpa2_ent.client_cert_path != NULL) {
774+
wpa_cert = pycom_util_read_file(wlan_wpa2_ent.client_key_path, &wlan_obj.vstr_key);
775+
if(wpa_cert == NULL) {
776+
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "device key certificate file not found"));
777+
}
778+
wpa_cert = pycom_util_read_file(wlan_wpa2_ent.client_cert_path, &wlan_obj.vstr_cert);
779+
if(wpa_cert == NULL) {
780+
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "device client certificate file not found"));
781+
}
782+
}
783+
}
784+
763785
// The certificate files are already read at this point because this function runs outside of GIL, and the file_read functions uses MicroPython APIs
764786
if (auth == WIFI_AUTH_WPA2_ENTERPRISE) {
765787
// CA Certificate is not mandatory

0 commit comments

Comments
 (0)
0