enterprise wifi, eduroam

asad786r
Posts: 3
Joined: Tue Jan 09, 2018 8:35 pm

enterprise wifi, eduroam

Postby asad786r » Tue Jan 09, 2018 8:47 pm

Hi,

I am quite new to esp32 and i am trying to connect to my schools eduroam wifi, i am using the arduino core with an esp32 devkitc esp32_core_board_v2

the wifi is

phase 2 authentication: MSCHAPV2
CA certificate: (unspecified)
Identity: my schools email address
anonymous identity: (blank)
password: my account password

im using the following arduino sketch

Code: Select all

#include "esp_wpa2.h"
#include <WiFi.h>

// WiFi network name and password:
const char* SSID = "eduroam"; // your ssid
#define EAP_ID "XXXXX@studentmail.XXX.ac.uk"  // your identity
#define EAP_USERNAME "" // your user id or username try email here aswell if not working otherwise blank ""
#define EAP_PASSWORD "Xxxxx11" // your password

// Internet domain to request from:
const char * hostDomain = "example.com";
const int hostPort = 80;

const int BUTTON_PIN = 0;
const int LED_PIN = 5;

void setup() {
// Initilize hardware:
Serial.begin(115200);
delay(10);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);

// Connect to the WiFi network (see function below loop)
connectToWiFi(SSID, EAP_ID, EAP_USERNAME, EAP_PASSWORD);

digitalWrite(LED_PIN, LOW); // LED off
Serial.print("Press button 0 to connect to ");
Serial.println(hostDomain);

}

void loop()
{
  if (digitalRead(BUTTON_PIN) == LOW)
  { // Check if button has been pressed
    while (digitalRead(BUTTON_PIN) == LOW)
      ; // Wait for button to be released

    digitalWrite(LED_PIN, HIGH); // Turn on LED
    requestURL(hostDomain, hostPort); // Connect to server
    digitalWrite(LED_PIN, LOW); // Turn off LED
  }
}

void connectToWiFi(const char * ssid, const char * id, const char * username, const char * password)
{
int ledState = 0;
printLine();
Serial.println("Connecting to WiFi network: " + String(ssid) + " ....with User Identity " + String(EAP_ID));

// WPA2 enterprise magic starts here
WiFi.disconnect(true); 
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)id, strlen(id));
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)username, strlen(username));
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)password, strlen(password));
// esp_wifi_sta_wpa2_ent_enable();
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); 
esp_wifi_sta_wpa2_ent_enable(&config);
// WPA2 enterprise magic ends here


WiFi.begin(ssid);

while (WiFi.status() != WL_CONNECTED) {
// Blink LED while we're connecting:
digitalWrite(LED_PIN, ledState);
ledState = (ledState + 1) % 2; // Flip ledState
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected!");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}

/* 
* everyhting below this, is just a standard request to a webserver to show that the wifi connection works.
* 
*/ 

void requestURL(const char * host, uint8_t port)
{
  printLine();
  Serial.println("Connecting to domain: " + String(host));

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  if (!client.connect(host, port))
  {
    Serial.println("connection failed");
    return;
  }
  Serial.println("Connected!");
  printLine();

// We now create a URI for the request
String url = "/index.htm";

Serial.print("Requesting URL: ");
Serial.println(url);

  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + String(host) + "\r\n" +
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) 
  {
    if (millis() - timeout > 5000) 
    {
      Serial.println(">>> Client Timeout !");
      client.stop();
      return;
    }
  }

  // Read all the lines of the reply from server and print them to Serial
  while (client.available()) 
  {
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }

  Serial.println();
  Serial.println("closing connection");
  client.stop();
}

void printLine()
{
  Serial.println();
  for (int i=0; i<30; i++)
    Serial.print("-");
  Serial.println();
}


the code compiles and uploads fine but i get a boot loop with the following message, in the serial console

Connecting to WiFi network: eduroam ....with User Identity xxxxx@studentmail.xxxx.ac.uk
......Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
. Exception was unhandled.
Register dump:
PC : 0x4012e2c1 PS : 0x00060130 A0 : 0x8012f028 A1 : 0x3ffdbb00
A2 : 0x3ffdca24 A3 : 0x00000001 A4 : 0x3ffdf19c A5 : 0x3ffdf19b
A6 : 0x00000002 A7 : 0x00000005 A8 : 0x8012e2bf A9 : 0x3ffdbae0
A10 : 0x00000000 A11 : 0x00000008 A12 : 0x3ffdca24 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000010 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000001 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000

Backtrace: 0x4012e2c1:0x3ffdbb00 0x4012f025:0x3ffdbb20 0x4012a59e:0x3ffdbb40 0x400dd67d:0x3ffdbb70 0x400dd863:0x3ffdbc20 0x400da676:0x3ffdbcf0 0x400daa5d:0x3ffdbd30 0x400d9d01:0x3ffdbdb0 0x400d9788:0x3ffdbe00 0x400d97e1:0x3ffdbe40 0x400d7ee4:0x3ffdbe60 0x400d7682:0x3ffdbea0 0x400d5cc5:0x3ffdbf00 0x400d601d:0x3ffdbf40

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:13076
entry 0x40078ad0

------------------------------
Connecting to WiFi network: eduroam ....with User Identity xxxxxxx@studentmail.xxx.ac.uk
......Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
. Exception was unhandled.
Register dump:
PC : 0x4012e2c1 PS : 0x00060b30 A0 : 0x8012f028 A1 : 0x3ffdbb00
A2 : 0x3ffdca24 A3 : 0x00000001 A4 : 0x3ffdf19c A5 : 0x3ffdf19b
A6 : 0x00000002 A7 : 0x00000005 A8 : 0x8012e2bf A9 : 0x3ffdbae0
A10 : 0x00000000 A11 : 0x00000008 A12 : 0x3ffdca24 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000010 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000001 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000

Backtrace: 0x4012e2c1:0x3ffdbb00 0x4012f025:0x3ffdbb20 0x4012a59e:0x3ffdbb40 0x400dd67d:0x3ffdbb70 0x400dd863:0x3ffdbc20 0x400da676:0x3ffdbcf0 0x400daa5d:0x3ffdbd30 0x400d9d01:0x3ffdbdb0 0x400d9788:0x3ffdbe00 0x400d97e1:0x3ffdbe40 0x400d7ee4:0x3ffdbe60 0x400d7682:0x3ffdbea0 0x400d5cc5:0x3ffdbf00 0x400d601d:0x3ffdbf40

Rebooting...


after a while it displays

Connecting to WiFi network: eduroam ....with User Identity b00162005@studentmail.uws.ac.uk
....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

with the waiting periods going on forever.

Any help would be appreciated thank you

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: enterprise wifi, eduroam

Postby ESP_Angus » Tue Jan 09, 2018 9:22 pm

Hi asad,

There are some known issues with WPA2 Enterprise and Eduroam, although this one looks a little different:
https://github.com/espressif/esp-idf/issues/1054

Are you able to decode the backtrace from this crash? You can do this via the Exception Decoder Tool for Arduino:
https://github.com/me-no-dev/EspExceptionDecoder

Angus

asad786r
Posts: 3
Joined: Tue Jan 09, 2018 8:35 pm

Re: enterprise wifi, eduroam

Postby asad786r » Thu Jan 11, 2018 6:30 pm

Hi Angus,

Thanks for helping me so far, sorry for the late reply, i havent had a chance to go into uni to test the wifi untill today.

I have done the backtrace like you asked using the Exception Decoder Tool for Arduino:

Code: Select all

Backtrace: 0x4012e2c1:0x3ffdbb00 0x4012f025:0x3ffdbb20 0x4012a59e:0x3ffdbb40 0x400dd67d:0x3ffdbb70 0x400dd863:0x3ffdbc20 0x400da676:0x3ffdbcf0 0x400daa5d:0x3ffdbd30 0x400d9d01:0x3ffdbdb0 0x400d9788:0x3ffdbe00 0x400d97e1:0x3ffdbe40 0x400d7ee4:0x3ffdbe60 0x400d7682:0x3ffdbea0 0x400d5cc5:0x3ffdbf00 0x400d601d:0x3ffdbf40
and this is the result:

Code: Select all

Decoding 14 results
0x4012b56d: mp_read_unsigned_bin at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/wpa_supplicant/src/crypto/libtommath.h line 990
0x4012c2d1: bignum_set_unsigned_bin at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/wpa_supplicant/src/crypto/bignum.c line 114
0x4012784a: crypto_mod_exp at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/wpa_supplicant/src/crypto/crypto_internal-modexp.c line 40
0x400dcd7d: x509_certificate_check_signature at ?? line ?
0x400dcf63: x509_certificate_chain_validate at ?? line ?
0x400d9d76: tlsv1_client_set_cred at ?? line ?
0x400da15d: tlsv1_client_process_handshake at ?? line ?
0x400d9401: tlsv1_client_handshake at ?? line ?
0x400d8e88: tls_connection_handshake2 at ?? line ?
0x400d8ee1: tls_connection_handshake at ?? line ?
0x400d75e4: eap_peer_tls_process_helper at ?? line ?
0x400d6d82: wifi_sta_get_enterprise_disable_time_check at ?? line ?
0x400d5385: eap_sm_process_request at ?? line ?
0x400d56dd: wpa2Task at ?? line ?
I hope this aids you into finding a solution, Thansk again for your help so far
Asad

Who is online

Users browsing this forum: ESP_Sprite, Google [Bot] and 189 guests