Skip to content

Commit 2c6f1e5

Browse files
committed
[nrf fromlist] net: l2: wifi: Handle domain match and suffix match parameters
Add support to handle domain match and suffix match parameters for proper server certification validation. Upstream PR #: 98190 Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
1 parent 7b600ee commit 2c6f1e5

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

include/zephyr/net/wifi_mgmt.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,16 @@ struct wifi_connect_req_params {
716716
uint8_t ignore_broadcast_ssid;
717717
/** Parameter used for frequency band */
718718
enum wifi_frequency_bandwidths bandwidth;
719+
720+
/** Full domain name to verify in the server certificate */
721+
const uint8_t *server_cert_domain_exact;
722+
/** Length of the server_cert_domain_exact string, maximum 128 bytes */
723+
uint8_t server_cert_domain_exact_len;
724+
725+
/** Domain name suffix to verify in the server certificate */
726+
const uint8_t *server_cert_domain_suffix;
727+
/** Length of the server_cert_domain_suffix string, maximum 64 bytes */
728+
uint8_t server_cert_domain_suffix_len;
719729
};
720730

721731
/** @brief Wi-Fi disconnect reason codes. To be overlaid on top of \ref wifi_status

modules/hostap/src/supp_api.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,22 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
970970
goto out;
971971
}
972972

973+
if (params->server_cert_domain_exact_len > 0) {
974+
if (!wpa_cli_cmd_v("set_network %d domain_match \"%s\"",
975+
resp.network_id,
976+
params->server_cert_domain_exact)) {
977+
goto out;
978+
}
979+
}
980+
981+
if (params->server_cert_domain_suffix_len > 0) {
982+
if (!wpa_cli_cmd_v("set_network %d domain_suffix_match \"%s\"",
983+
resp.network_id,
984+
params->server_cert_domain_suffix)) {
985+
goto out;
986+
}
987+
}
988+
973989
if (false == ((params->security == WIFI_SECURITY_TYPE_EAP_PEAP_MSCHAPV2 ||
974990
params->security == WIFI_SECURITY_TYPE_EAP_TTLS_MSCHAPV2) &&
975991
(!params->verify_peer_cert))) {

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
620620
{"ignore-broadcast-ssid", required_argument, 0, 'g'},
621621
{"ieee-80211r", no_argument, 0, 'R'},
622622
{"iface", required_argument, 0, 'i'},
623+
{"server-cert-domain-exact", required_argument, 0, 'e'},
624+
{"server-cert-domain-suffix", required_argument, 0, 'x'},
623625
{"help", no_argument, 0, 'h'},
624626
{0, 0, 0, 0}};
625627
char *endptr;
@@ -872,6 +874,16 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
872874
case 'i':
873875
/* Unused, but parsing to avoid unknown option error */
874876
break;
877+
case 'e':
878+
params->server_cert_domain_exact = state->optarg;
879+
params->server_cert_domain_exact_len =
880+
strlen(params->server_cert_domain_exact);
881+
break;
882+
case 'x':
883+
params->server_cert_domain_suffix = state->optarg;
884+
params->server_cert_domain_suffix_len =
885+
strlen(params->server_cert_domain_suffix);
886+
break;
875887
case 'h':
876888
return -ENOEXEC;
877889
default:
@@ -3921,10 +3933,12 @@ SHELL_SUBCMD_ADD((wifi), connect, NULL,
39213933
"[-P, --eap-pwd1]: Client Password.\n"
39223934
"Default no password for eap user.\n"
39233935
"[-R, --ieee-80211r]: Use IEEE80211R fast BSS transition connect."
3936+
"[-e, --server-cert-domain-exact]: Full domain names for server certificate match.\n"
3937+
"[-x, --server-cert-domain-suffix]: Domain name suffixes for server certificate match.\n"
39243938
"[-h, --help]: Print out the help for the connect command.\n"
39253939
"[-i, --iface=<interface index>] : Interface index.\n",
39263940
cmd_wifi_connect,
3927-
2, 42);
3941+
2, 46);
39283942

39293943
SHELL_SUBCMD_ADD((wifi), disconnect, NULL,
39303944
"Disconnect from the Wi-Fi AP.\n"

0 commit comments

Comments
 (0)