-->
Page 1 of 1

How can I connect to WPA2-Enterprise EAP-TLS by ESP8266MOD?

PostPosted: Fri Aug 31, 2018 2:24 am
by scott.sanchez1975
Hi everyone,
I have a troubles with getting access to WLAN secured by WPA2-Enterprise EAP-TLS using ESP8266 and Arduino IDE. Is there any solution, to do it?
I have p12 certificate to do connect, so I extracted from it two files privateKey and publicCert and turned both to *.h files. Using joostd's code which can be found here I can't get access to wlan. Even Radius doesn't have any trace of try to connect by my ESP.

But, there is another code which leave a trace on Radius, but Radius shows that "Client doesn't support EAP." I know, that ESP8266 supports eap-tls connection. So, how can I solve this problem? Any solutions? Has anybody solve the same or similar issue?

Here is a code which leave the trace in Radius, but can't get access (I don't know author):
Code: Select all#include  <ESP8266WiFi.h>

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

// SSID to connect to
char ssid[] = "ssid";
char wlpasswd[] = "";
char username[] = "user";
char identity[] = "user";
char password[] = "";
char new_password[] = "";

const char* username1 = "user1";

u8 ca_cert[] = "-----BEGIN CERTIFICATE-----\n"
"................here is my certificate...............\n"
"-----END CERTIFICATE-----";

void setup() {

  WiFi.mode(WIFI_STA);
  Serial.begin(115200);
  delay(1000);
  Serial.setDebugOutput(true);
  Serial.printf("SDK version: %s\n", system_get_sdk_version());
  Serial.printf("Free Heap: %4d\n",ESP.getFreeHeap());
 
  // Setting ESP into STATION mode only (no AP mode or dual mode)
  wifi_set_opmode(STATION_MODE);

  struct station_config wifi_config;

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

  wifi_station_set_config(&wifi_config);

 

  wifi_station_set_wpa2_enterprise_auth(1);

  // Clean up to be sure no old data is still inside
  wifi_station_clear_cert_key();
  wifi_station_clear_enterprise_ca_cert();
  wifi_station_clear_enterprise_identity();
  wifi_station_clear_enterprise_username();
  wifi_station_clear_enterprise_password();
  wifi_station_clear_enterprise_new_password();
 
  wifi_station_set_enterprise_identity((uint8*)username1, strlen(username1));
  wifi_station_set_enterprise_ca_cert(ca_cert, sizeof(ca_cert));
 
  wifi_station_set_enterprise_identity((uint8*)identity, strlen(identity));
  wifi_station_set_enterprise_username((uint8*)username, strlen(username));
  //wifi_station_set_enterprise_password((uint8*)password, strlen((char*)password));
  //wifi_station_set_enterprise_new_password((uint8*)new_password, strlen(new_password));
  //wifi_station_set_enterprise_ca_cert(ca_pem, ca_pem_len);

 
  wifi_station_connect();
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }

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

void loop() {
}


Problem solved! ;)