Skip to content

Added another overloaded WiFiSTAClass::begin() function that provides… #6398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libraries/WiFi/src/WiFiGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
#include "esp_smartconfig.h"
#include "wifi_provisioning/manager.h"

#ifdef ENABLE_WPA2_AUTHENTICATION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it need to be disabled? Would it not work for all chips/cases? Having it guarded like that would require some way to enable this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had this guard in there because I wasn't sure if there was any shared code between the WiFi portions of the Arduino cores for ESP8266 and ESP32. AFAIK based on fairly recent testing, I don't think the WPA2 Enterprise authentication works for ESP8266, so I was thinking ahead to try and make it capable of being guarded easily. I can remove those, if you want me to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the client nowhere being used other than to set some certs that yu provide as arguments to the function. You should be able to safely skip those and add them to the sketch. BTW could you please provide an example of the use?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh pr checkout 6398 hey
I cant help someone tied the SWAN CAMERA SYSTEM TO MY COMPUTER

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a company profile on linkedin that can be used to identify me currently, a IBM is a computer of the guy that is stealing my identity.

#include <WiFiClient.h>
#include <WiFiClientSecure.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are those two included? Just esp_wpa2.h is enough, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that esp_wpa2.h is enough. If you look just above the new WiFiSTAClass::begin() function that I created, I declared a static WiFiClientSecure. This is necessary for negotiating the various types of cert processes that are sometimes needed with WPA2 Enterprise. esp_wpa2.h does not include WiFiClientSecure.h, as the former is a esp-idf header and the latter is an arduino-espressif32 header.

I could/should arguably move these into the WiFiSTA.cpp file (and I don't think I actually need WiFiClient.h) to prevent unnecessary #includes, however.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes please :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSVALIDATE.01 ¤ "Meta"
-----[\HTTPS://BITCOINNEWS.COM----]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is was is s someone added their Business camera sytem to my computer... now i have identity issues

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Screwballs"tied his camera system to my computer... now i cannot access any of my own stuff
20220405_174156

#include "esp_wpa2.h"
#endif

ESP_EVENT_DECLARE_BASE(ARDUINO_EVENTS);

typedef enum {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔🛫🛫🛫✔🛫🛫🔗 👋👋👋

D VERSION:3. 0 N: FN: EMAIL;TYPE=PREF:hello@247atmformula. com END:VCARD
[email protected]📁📂👋

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand Down
72 changes: 72 additions & 0 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,78 @@ wl_status_t WiFiSTAClass::status()
return (wl_status_t)xEventGroupClearBits(_sta_status_group, 0);
}


#ifdef ENABLE_WPA2_AUTHENTICATION
static WiFiClientSecure client_secure;

/**
* Start Wifi connection with a WPA2 Enterprise AP
* if passphrase is set the most secure supported mode will be automatically selected
* @param ssid const char* Pointer to the SSID string.
* @param wpa2_identity const char* Pointer to the entity
* @param wpa2_username const char* Pointer to the username
* @param password const char * Pinter to the password.
* @param root_ca const char* Optional. Pointer to the root certificate string.
* @param client_cert const char* Optional. Pointer to the client certificate string.
* @param client_key const char* Optional. Pointer to the client key.
* @param bssid uint8_t[6] Optional. BSSID / MAC of AP
* @param channel Optional. Channel of AP
* @param connect Optional. call connect
* @return
*/
wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, const char* wpa2_identity, const char* wpa2_username, const char *wpa2_password, const char* root_ca, const char* client_cert, const char* client_key, int32_t channel, const uint8_t* bssid, bool connect)
{
if(!WiFi.enableSTA(true)) {
log_e("STA enable failed!");
return WL_CONNECT_FAILED;
}

if(!wpa2_ssid || *wpa2_ssid == 0x00 || strlen(wpa2_ssid) > 32) {
log_e("SSID too long or missing!");
return WL_CONNECT_FAILED;
}

if(wpa2_identity && strlen(wpa2_identity) > 64) {
log_e("identity too long!");
return WL_CONNECT_FAILED;
}

if(wpa2_username && strlen(wpa2_username) > 64) {
log_e("username too long!");
return WL_CONNECT_FAILED;
}

if(wpa2_password && strlen(wpa2_password) > 64) {
log_e("password too long!");
}

esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity));
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)wpa2_username, strlen(wpa2_username));
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)wpa2_password, strlen(wpa2_password));
esp_wifi_sta_wpa2_ent_enable(); //set config settings to enable function
WiFi.begin(wpa2_ssid); //connect to wifi

int cert_count = (root_ca != NULL) + (client_cert != NULL) + (client_key != NULL);
if ( cert_count > 1 ) {
log_e("only one cert method allowed!");
return WL_CONNECT_FAILED;
}

if (root_ca != NULL) {
client_secure.setCACert(root_ca);
}
else if (client_cert != NULL) {
client_secure.setCertificate(client_cert);
}
else if (client_key != NULL) {
client_secure.setPrivateKey(client_key);
}
return status();
}
#endif



/**
* Start Wifi connection
* if passphrase is set the most secure supported mode will be automatically selected
Expand Down
3 changes: 3 additions & 0 deletions libraries/WiFi/src/WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class WiFiSTAClass

public:

#ifdef ENABLE_WPA2_AUTHENTICATION
wl_status_t begin(const char* wpa2_ssid, const char* wpa2_identity, const char* wpa2_username, const char *wpa2_password, const char* root_ca=NULL, const char* client_cert=NULL, const char* client_key=NULL,int32_t channel=0, const uint8_t* bssid=0, bool connect=true);
#endif
wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true);
wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true);
wl_status_t begin();
Expand Down