diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c index 9258f77c2..9142137ab 100644 --- a/src/nm-device-wifi.c +++ b/src/nm-device-wifi.c @@ -1460,6 +1460,26 @@ real_complete_connection (NMDevice *device, if (ap) { ssid = nm_ap_get_ssid (ap); + if (ssid == NULL) { + /* The AP must be hidden. Connecting to a WiFi AP requires the SSID + * as part of the initial handshake, so check the connection details + * for the SSID. The AP object will still be used for encryption + * settings and such. + */ + ssid = nm_setting_wireless_get_ssid (s_wifi); + } + + if (ssid == NULL) { + /* If there's no SSID on the AP itself, and no SSID in the + * connection data, then we cannot connect at all. Return an error. + */ + g_set_error_literal (error, + NM_WIFI_ERROR, + NM_WIFI_ERROR_CONNECTION_INVALID, + "A 'wireless' setting with a valid SSID is required for hidden access points."); + return FALSE; + } + /* If the SSID is a well-known SSID, lock the connection to the AP's * specific BSSID so NM doesn't autoconnect to some random wifi net. */