Skip to content

Commit f1b4a02

Browse files
kapilkedawatespressif-bot
authored andcommitted
esp_examples: Update WiFi enterprise example
1 parent 54940f5 commit f1b4a02

File tree

17 files changed

+78
-41
lines changed

17 files changed

+78
-41
lines changed

docs/en/api-guides/wifi.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ For establishing a secure connection, AP and Station negotiate and agree on the
14281428
- MSCHAP and MSCHAP-V2.
14291429

14301430

1431-
Detailed information on creating certificates and how to run wpa2_enterprise example on {IDF_TARGET_NAME} can be found in :example:`wifi/wpa2_enterprise`.
1431+
Detailed information on creating certificates and how to run wpa2_enterprise example on {IDF_TARGET_NAME} can be found in :example:`wifi/wifi_enterprise`.
14321432

14331433
.. only:: esp32s2 or esp32c3
14341434

File renamed without changes.
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WPA2 Enterprise Example
22

3-
This example shows how ESP32 connects to AP with wpa2 enterprise encryption. Example does the following steps:
3+
This example shows how ESP32 connects to AP with Wi-Fi enterprise encryption. The example does the following steps:
44

55
1. Install CA certificate which is optional.
66
2. Install client certificate and client key which is required in TLS method and optional in PEAP and TTLS methods.
@@ -9,12 +9,13 @@ This example shows how ESP32 connects to AP with wpa2 enterprise encryption. Exa
99
5. Enable wpa2 enterprise.
1010
6. Connect to AP.
1111

12-
*Note:* 1. The certificates currently are generated and are present in examples.wifi/wpa2_enterprise/main folder.
12+
*Note:* 1. The certificates currently are generated and are present in examples/wifi/wifi_enterprise/main folder.
1313
2. The expiration date of the certificates is 2027/06/05.
14+
3. In case using suite-b, please use appropriate certificates such as RSA-3072 or p384 EC certificates.
1415

1516
The steps to create new certificates are given below.
1617

17-
## The file wpa2_ca.pem, wpa2_ca.key, wpa2_server.pem, wpa2_server.crt and wpa2_server.key can be used to configure AP with wpa2 enterprise encryption.
18+
## The file ca.pem, ca.key, server.pem, server.crt and server.key can be used to configure AP with enterprise encryption.
1819

1920
## How to use Example
2021

@@ -36,7 +37,7 @@ idf.py menuconfig
3637
idf.py -p PORT flash monitor
3738
```
3839

39-
## Steps to create wpa2_ent openssl certs
40+
## Steps to create enterprise openssl certs
4041

4142
1. make directry tree
4243

@@ -56,27 +57,27 @@ idf.py -p PORT flash monitor
5657
extendedKeyUsage = 1.3.6.1.5.5.7.3.1
5758

5859
2. ca.pem: root certificate, foundation of certificate verigy
59-
openssl req -new -x509 -keyout wpa2_ca.key -out wpa2_ca.pem
60+
openssl req -new -x509 -keyout ca.key -out ca.pem
6061

6162
3. generate rsa keys for client and server
62-
openssl genrsa -out wpa2_client.key 2048
63-
openssl genrsa -out wpa2_server.key 2048
63+
openssl genrsa -out client.key 2048
64+
openssl genrsa -out server.key 2048
6465

6566
4. generate certificate signing req for both client and server
66-
openssl req -new -key wpa2_client.key -out wpa2_client.csr
67-
openssl req -new -key wpa2_server.key -out wpa2_server.csr
67+
openssl req -new -key client.key -out client.csr
68+
openssl req -new -key server.key -out server.csr
6869

6970
5. create certs (.crt) for client nd server
70-
openssl ca -batch -keyfile wpa2_ca.key -cert wpa2_ca.pem -in wpa2_client.csr -key (password) -out wpa2_client.crt -extensions xpserver_ext -extfile xpextensions
71-
openssl ca -batch -keyfile wpa2_ca.key -cert wpa2_ca.pem -in wpa2_server.csr -key (password) -out wpa2_server.crt -extensions xpserver_ext -extfile xpextensions
71+
openssl ca -batch -keyfile ca.key -cert ca.pem -in client.csr -key (password) -out client.crt -extensions xpserver_ext -extfile xpextensions
72+
openssl ca -batch -keyfile ca.key -cert ca.pem -in server.csr -key (password) -out server.crt -extensions xpserver_ext -extfile xpextensions
7273

7374
6. export .p12 files
74-
openssl pkcs12 -export -out wpa2_client.p12 -inkey wpa2_client.key -in wpa2_client.crt
75-
openssl pkcs12 -export -out wpa2_server.p12 -inkey wpa2_server.key -in wpa2_server.crt
75+
openssl pkcs12 -export -out client.p12 -inkey client.key -in client.crt
76+
openssl pkcs12 -export -out server.p12 -inkey server.key -in server.crt
7677

7778
7. create .pem files
78-
openssl pkcs12 -in wpa2_client.p12 -out wpa2_client.pem
79-
openssl pkcs12 -in wpa2_server.p12 -out wpa2_server.pem
79+
openssl pkcs12 -in client.p12 -out client.pem
80+
openssl pkcs12 -in server.p12 -out server.pem
8081

8182

8283

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Embed CA, certificate & key directly into binary
2+
idf_component_register(SRCS "wifi_enterprise_main.c"
3+
INCLUDE_DIRS "."
4+
EMBED_TXTFILES ca.pem client.crt client.key)

examples/wifi/wpa2_enterprise/main/Kconfig.projbuild renamed to examples/wifi/wifi_enterprise/main/Kconfig.projbuild

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
menu "Example Configuration"
22

3+
choice
4+
prompt "Enterprise configuration to be used"
5+
default EXAMPLE_WPA_WPA2_ENTERPRISE
6+
config EXAMPLE_WPA_WPA2_ENTERPRISE
7+
bool "WPA_WPA2_ENT"
8+
config EXAMPLE_WPA3_ENTERPRISE
9+
bool "WPA3_ENT"
10+
config EXAMPLE_WPA3_192BIT_ENTERPRISE
11+
bool "WPA3_192BIT_ENT"
12+
depends on IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3
13+
endchoice
14+
315
config EXAMPLE_WIFI_SSID
416
string "WiFi SSID"
517
default "wpa2_test"
618
help
719
SSID (network name) for the example to connect to.
820

9-
config EXAMPLE_VALIDATE_SERVER_CERT
10-
bool "Validate server"
11-
default y
12-
help
13-
Validate the servers' certificate using CA cert.
21+
if EXAMPLE_WPA_WPA2_ENTERPRISE
22+
config EXAMPLE_VALIDATE_SERVER_CERT
23+
bool "Validate server"
24+
default y
25+
help
26+
Validate the servers' certificate using CA cert.
27+
endif
28+
29+
if !EXAMPLE_WPA_WPA2_ENTERPRISE
30+
config EXAMPLE_VALIDATE_SERVER_CERT
31+
default y
32+
endif
1433

1534
choice
1635
prompt "EAP method for the example to use"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)