Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions doc/connectivity/networking/api/wifi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,29 @@ To initiate a Wi-Fi connection using enterprise security, use one of the followi
Server certificate is also provided in the same directory for testing purposes.
Any AAA server can be used for testing purposes, for example, ``FreeRADIUS`` or ``hostapd``.

Server certificate domain name verification
-------------------------------------------

The authentication server’s identity is verified by validating the domain name in the X.509 certificate received from the server, using the ``Common Name`` (CN) field.

* Exact domain match — Verifies that the certificate’s CN exactly matches the specified domain.

* Domain suffix match — Allows a certificate whose CN ends with the specified domain suffix.

To initiate a Wi-Fi connection using enterprise security with server certificate validation, use one of the following commands, depending on the desired validation mode:

* Exact domain match

.. code-block:: console

wifi connect -s <SSID> -c <channel> -k 12 -K <Private key Password> -e <Domain match>

* Domain suffix match

.. code-block:: console

wifi connect -s <SSID> -c <channel> -k 12 -K <Private key Password> -x <Domain suffix name>

Certificate requirements for EAP methods
----------------------------------------

Expand Down
10 changes: 10 additions & 0 deletions include/zephyr/net/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,16 @@ struct wifi_connect_req_params {
uint8_t ignore_broadcast_ssid;
/** Parameter used for frequency band */
enum wifi_frequency_bandwidths bandwidth;

/** Full domain name to verify in the server certificate */
const uint8_t *server_cert_domain_exact;
/** Length of the server_cert_domain_exact string, maximum 128 bytes */
uint8_t server_cert_domain_exact_len;

/** Domain name suffix to verify in the server certificate */
const uint8_t *server_cert_domain_suffix;
/** Length of the server_cert_domain_suffix string, maximum 64 bytes */
uint8_t server_cert_domain_suffix_len;
};

/** @brief Wi-Fi disconnect reason codes. To be overlaid on top of \ref wifi_status
Expand Down
4 changes: 4 additions & 0 deletions modules/hostap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ zephyr_library_compile_definitions_ifdef(CONFIG_EAP_FAST
EAP_FAST
)

zephyr_library_compile_definitions_ifdef(CONFIG_EAP_TLSV1_3
EAP_TLSV1_3
)

zephyr_library_sources_ifdef(CONFIG_WIFI_NM_WPA_SUPPLICANT_EAPOL
${HOSTAP_SRC_BASE}/eapol_supp/eapol_supp_sm.c
${HOSTAP_SRC_BASE}/eap_peer/eap.c
Expand Down
8 changes: 8 additions & 0 deletions modules/hostap/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ config EAP_ALL
select EAP_TTLS
select EAP_MSCHAPV2
default y

config EAP_TLSV1_3
bool "EAP TLSv1.3 support"
select MBEDTLS_TLS_VERSION_1_3
select MBEDTLS_TLS_SESSION_TICKETS
select MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
select MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
select MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
endif # WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE

config WIFI_NM_WPA_SUPPLICANT_WPA3
Expand Down
16 changes: 16 additions & 0 deletions modules/hostap/src/supp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,22 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
goto out;
}

if (params->server_cert_domain_exact_len > 0) {
if (!wpa_cli_cmd_v("set_network %d domain_match \"%s\"",
resp.network_id,
params->server_cert_domain_exact)) {
goto out;
}
}

if (params->server_cert_domain_suffix_len > 0) {
if (!wpa_cli_cmd_v("set_network %d domain_suffix_match \"%s\"",
resp.network_id,
params->server_cert_domain_suffix)) {
goto out;
}
}

if (false == ((params->security == WIFI_SECURITY_TYPE_EAP_PEAP_MSCHAPV2 ||
params->security == WIFI_SECURITY_TYPE_EAP_TTLS_MSCHAPV2) &&
(!params->verify_peer_cert))) {
Expand Down
16 changes: 15 additions & 1 deletion subsys/net/l2/wifi/wifi_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@
{"ignore-broadcast-ssid", required_argument, 0, 'g'},
{"ieee-80211r", no_argument, 0, 'R'},
{"iface", required_argument, 0, 'i'},
{"server-cert-domain-exact", required_argument, 0, 'e'},
{"server-cert-domain-suffix", required_argument, 0, 'x'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}};
char *endptr;
Expand Down Expand Up @@ -872,6 +874,16 @@
case 'i':
/* Unused, but parsing to avoid unknown option error */
break;
case 'e':
params->server_cert_domain_exact = state->optarg;
params->server_cert_domain_exact_len =
strlen(params->server_cert_domain_exact);
break;
case 'x':
params->server_cert_domain_suffix = state->optarg;
params->server_cert_domain_suffix_len =
strlen(params->server_cert_domain_suffix);
break;

Check notice on line 886 in subsys/net/l2/wifi/wifi_shell.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/l2/wifi/wifi_shell.c:886 - strlen(params->server_cert_domain_exact); + strlen(params->server_cert_domain_exact); break; case 'x': params->server_cert_domain_suffix = state->optarg; params->server_cert_domain_suffix_len = - strlen(params->server_cert_domain_suffix); + strlen(params->server_cert_domain_suffix);
case 'h':
return -ENOEXEC;
default:
Expand Down Expand Up @@ -3921,11 +3933,13 @@
"[-P, --eap-pwd1]: Client Password.\n"
"Default no password for eap user.\n"
"[-R, --ieee-80211r]: Use IEEE80211R fast BSS transition connect."
"[-e, --server-cert-domain-exact]: Full domain names for server certificate match.\n"
"[-x, --server-cert-domain-suffix]: Domain name suffixes for server certificate match.\n"
"[-h, --help]: Print out the help for the connect command.\n"
"[-i, --iface=<interface index>] : Interface index.\n",
cmd_wifi_connect,
2, 42);
2, 46);

Check notice on line 3942 in subsys/net/l2/wifi/wifi_shell.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/l2/wifi/wifi_shell.c:3942 -SHELL_SUBCMD_ADD((wifi), connect, NULL, - "Connect to a Wi-Fi AP\n" - "<-s --ssid \"<SSID>\">: SSID.\n" - "[-c --channel]: Channel that needs to be scanned for connection. " - "0:any channel.\n" - "[-b, --band] 0: any band (2:2.4GHz, 5:5GHz, 6:6GHz]\n" - "[-p, --passphrase]: Passphrase (valid only for secure SSIDs)\n" - "[-k, --key-mgmt]: Key Management type (valid only for secure SSIDs)\n" - "0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE-HNP, 4:SAE-H2E, 5:SAE-AUTO, 6:WAPI," - "7:EAP-TLS, 8:WEP, 9: WPA-PSK, 10: WPA-Auto-Personal, 11: DPP\n" - "12: EAP-PEAP-MSCHAPv2, 13: EAP-PEAP-GTC, 14: EAP-TTLS-MSCHAPv2,\n" - "15: EAP-PEAP-TLS, 20: SAE-EXT-KEY\n" - "[-w, --ieee-80211w]: MFP (optional: needs security type to be specified)\n" - ": 0:Disable, 1:Optional, 2:Required.\n" - "[-m, --bssid]: MAC address of the AP (BSSID).\n" - "[-t, --timeout]: Timeout for the connection attempt (in seconds).\n" - "[-a, --anon-id]: Anonymous identity for enterprise mode.\n" - "[-K, --key1-pwd for eap phase1 or --key2-pwd for eap phase2]:\n" - "Private key passwd for enterprise mode. Default no password for private key.\n" - "[-S, --wpa3-enterprise]: WPA3 enterprise mode:\n" - "Default 0: Not WPA3 enterprise mode.\n" - "1:Suite-b mode, 2:Suite-b-192-bit mode, 3:WPA3-enterprise-only mode.\n" - "[-T, --TLS-cipher]: 0:TLS-NONE, 1:TLS-ECC-P384, 2:TLS-RSA-3K.\n" - "[-A, --verify-peer-cert]: apply for EAP-PEAP-MSCHAPv2 and EAP-TTLS-MSCHAPv2\n" - "Default 0. 0:not use CA to verify peer, 1:use CA to verify peer.\n" - "[-V, --eap-version]: 0 or 1. Default 1: eap version 1.\n" - "[-I, --eap-id1]: Client Identity. Default no eap identity.\n" - "[-P, --eap-pwd1]: Client Password.\n" - "Default no password for eap user.\n" - "[-R, --ieee-80211r]: Use IEEE80211R fast BSS transition connect." - "[-e, --server-cert-domain-exact]: Full domain names for server certificate match.\n" - "[-x, --server-cert-domain-suffix]: Domain name suffixes for server certificate match.\n" - "[-h, --help]: Print out the help for the connect command.\n" - "[-i, --iface=<interface index>] : Interface index.\n", - cmd_wifi_connect, - 2, 46); +SHELL_SUBCMD_ADD( + (wifi), connect, NULL, + "Connect to a Wi-Fi AP\n" + "<-s --ssid \"<SSID>\">: SSID.\n" + "[-c --channel]: Channel that needs to be scanned for connection. " + "0:any channel.\n" + "[-b, --band] 0: any band (2:2.4GHz, 5:5GHz, 6:6GHz]\n" + "[-p, --passphrase]: Passphrase (valid only for secure SSIDs)\n" + "[-k, --key-mgmt]: Key Management type (valid only for secure SSIDs)\n" + "0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE-HNP, 4:SAE-H2E, 5:SAE-AUTO, 6:WAPI," + "7:EAP-TLS, 8:WEP, 9: WPA-PSK, 10: WPA-Auto-Personal, 11: DPP\n" + "12: EAP-PEAP-MSCHAPv2, 13: EAP-PEAP-GTC, 14: EAP-TTLS-MSCHAPv2,\n" + "15: EAP-PEAP-TLS, 20: SAE-EXT-KEY\n" + "[-w, --ieee-80211w]: MFP (optional: needs security type to be specified)\n" + ": 0:Disable, 1:Optional, 2:Required.\n" + "[-m, --bssid]: MAC address of the AP (BSSID).\n" + "[-t, --timeout]: Timeout for the connection attempt (in seconds).\n" + "[-a, --anon-id]: Anonymous identity for enterprise mode.\n" + "[-K, --key1-pwd for eap phase1 or --key2-pwd for eap phase2]:\n" + "Private key passwd for enterprise mode. Default no password for private key.\n" + "[-S, --wpa3-enterprise]: WPA3 enterprise mode:\n" + "Default 0: Not WPA3 enterprise mode.\n" + "1:Suite-b mode, 2:Suite-b-192-bit mode, 3:WPA3-enterprise-only mode.\n" + "[-T, --TLS-cipher]: 0:TLS-NONE, 1:TLS-ECC-P384, 2:TLS-RSA-3K.\n" + "[-A, --verify-peer-cert]: apply for EAP-PEAP-MSCHAPv2 and EAP-TTLS-MSCHAPv2\n" + "Default 0. 0:not use CA to verify peer, 1:use CA to verify peer.\n" + "[-V, --eap-version]: 0 or 1. Default 1: eap version 1.\n" + "[-I, --eap-id1]: Client Identity. Default no eap identity.\n" + "[-P, --eap-pwd1]: Client Password.\n" + "Default no password for eap user.\n" + "[-R, --ieee-80211r]: Use IEEE80211R fast BSS transition connect." + "[-e, --server-cert-domain-exact]: Full domain names for server certificate match.\n"
SHELL_SUBCMD_ADD((wifi), disconnect, NULL,
"Disconnect from the Wi-Fi AP.\n"
"[-i, --iface=<interface index>] : Interface index.\n",
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ manifest:
- hal
- name: hostap
path: modules/lib/hostap
revision: 5abcff1c0ecff65f0f81e0cc086b7f766e5101bf
revision: 6086dea5ee7406e1eede7f2ca6dff1b00b0f04e2
- name: liblc3
revision: 48bbd3eacd36e99a57317a0a4867002e0b09e183
path: modules/lib/liblc3
Expand Down
Loading