esp8266 / esp8266/Arduino

trying with WPA2-enterprise on a TP-Link EAP with external Radius Server

Open
#4,698 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

#### Platform

- Hardware: [ESP-12]
- Core Version: [latest git/2.4.1]
- Development Env: [Arduino IDE]
- Operating System: [Windows]

### Settings in IDE

- Module: [Nodemcu 0.9]
- Flash Mode: [qio]
- Flash Size: [4MB/1MB]
- lwip Variant: [v1.4|v2 Lower Memory]
- Reset Method: [ck|nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [160MHz]
- Upload Using: [SERIAL]
- Upload Speed: [921600]

### Problem Description
I am trying to connect an ESP to wpa2 network at my university. it keeps looping between scandone, and trying to connect, then disconnect. I tried so many variations based on different examples that people say worked for them, this is kind of a jamboree of such code. I also tried with eduroam and pretty much the same result.

Once user mentioned he had this working on 2.4.0, so I went back to that version from 2.4.1, yet no success with that either.

###Edit: I got a test enterprise router, and am testing with an external radius router now.

### [MCVE](https://stackoverflow.com/help/mcve) Sketch

```cpp

#include "ESP8266WiFi.h"
extern "C" {
#include "user_interface.h"
#include "wpa2_enterprise.h"
}

static const char* ssid = "UB_Secure";
static const char* username = testUser";//
static const char* password = "testpswd";
const char* host = "host_ip";
const char* username1 = "testUser"; //based on a comment on forum

u8 ca_cert[] = "-----BEGIN CERTIFICATE-----\n"
"MIIFETCCA/mgAwIBAgIJAO0ntD34r/+QMA0GCSqGSIb3DQEBCwUAMIGiMQswCQYD\n"
"VQQGEwJVUzEXMBUGA1UECAwOTm9ydGggQ2Fyb2xpbmExDzANBgNVBAcMBkR1cmhh\n"
"bTEeMBwGA1UECgwVTWl0Y2hlbGwvVHJhbXBlciBJbmMuMR8wHQYJKoZIhvcNAQkB\n"
"FhBidXJ0bXNAZ21haWwuY29tMSgwJgYDVQQDDB9CdXJ0IFNlbGYgQ2VydGlmaWNh\n"
"dGUgQXV0aG9yaXR5MB4XDTE4MDEyM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q9+K//kDAPBgNVHRMB\n"
"Af8EBTADAQH/MDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly93d3cuZXhhbXBsZS5v\n"
"cmcvZXhhbXBsZV9jYS5jcmwwDQYJKoZIhvcNAQELBQADggEBADNmDxddEh1XSo8J\n"
"fanCRuYqngpVFtKCzRNCtQ7aOAPrj6gRMtMAqQhlYmcbxjaVOCboAvJ8evY8x5We\n"
"YU6eIAmg95PlDws8EvcVQhO2ZYcuOHTvdu5Q4Ior0oXaCfqdS35YcPW7pRGprY/x\n"
"w7kbG84FFatpXPuDGQB65haqQ2KXPrILiE/jAKpTu9EBLEEN4uIAuxbB6unARovX\n"
"YoXIQHFc32bZAjihquvs4J7FNkcSr3lJpuv03dryqMB+Qn3G8yM7PFLNL2QyS0Zu\n"
"UbS5kDO7UqbTjtrUDolp5sUNvyrkX5ILYfZeEeaHqAlA20SFqNG7BcTY222NsCft\n"
"yNXqX1c=\n"
"-----END CERTIFICATE-----";
void setup() {
Serial.begin(115200);

Serial.print("Connecting to ");
Serial.println(ssid);
// Setting ESP into STATION mode only (no AP mode or dual mode)
wifi_set_opmode(0x01);

struct station_config wifi_config;

memset(&wifi_config, 0, sizeof(wifi_config));
strcpy((char*)wifi_config.ssid, ssid);

wifi_station_set_config(&wifi_config);

wifi_station_clear_cert_key();
wifi_station_clear_enterprise_ca_cert();

wifi_station_set_wpa2_enterprise_auth(1);
wifi_station_set_enterprise_identity((uint8*)username1, strlen(username1));
wifi_station_set_enterprise_ca_cert(ca_cert, sizeof(ca_cert));
wifi_station_set_enterprise_username((uint8*)username, strlen(username));
wifi_station_set_enterprise_password((uint8*)password, strlen(password));

wifi_station_connect();
Serial.print("Wifi station connect status:");
Serial.println(wifi_station_get_connect_status());

// Wait for connection AND IP address from DHCP
while (WiFi.status() != WL_CONNECTED) {
Serial.println(WiFi.status());
delay(2000);
Serial.println("Not connected");
}

Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

void loop()
{
delay(2000);
}
```

### Debug Messages

```

SDK:2.2.1(cfd48f3)/Core:2.4.1/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1)
Connecting to UB_Secure
WPA2 ENTERPRISE VERSION: [v2.0] enable
scandone
Wifi station connect status:1
6
wifi evt: 8
wifi evt: 2
Not connected
6
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (4)
reconnect
wifi evt: 1
STA disconnect: 4
Not connected
6
Not connected
6
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt
Not connected
6
Not connected
6
Not connected
6
Not connected
6
pm open,type:2 0
Not connected
6
Not connected
6
Not connected
6
Not connected
6
Not connected
6
Not connected
6
Not connected
6
Not connected
6
Not connected
6
Not connected
6
state: 5 -> 0 (2)
rm 0
pm close 7
reconnect
wifi evt: 1
STA disconnect: 204
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (4)
reconnect
wifi evt: 1
STA disconnect: 4
scandone
wifi evt: 1
STA disconnect: 201
Not connected
4
reconnect
Not connected
4
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.