blob: fefc0d375fe8906b461e435707bc1219955ac3f3 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001WPA Supplicant
2==============
3
Dmitry Shmidtde47be72016-01-07 12:52:55 -08004Copyright (c) 2003-2016, Jouni Malinen <j@w1.fi> and contributors
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07005All Rights Reserved.
6
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08007This program is licensed under the BSD license (the one with
8advertisement clause removed).
9
10If you are submitting changes to the project, please see CONTRIBUTIONS
11file for more instructions.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070012
13
14
15License
16-------
17
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -080018This software may be distributed, used, and modified under the terms of
19BSD license:
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070020
21Redistribution and use in source and binary forms, with or without
22modification, are permitted provided that the following conditions are
23met:
24
251. Redistributions of source code must retain the above copyright
26 notice, this list of conditions and the following disclaimer.
27
282. Redistributions in binary form must reproduce the above copyright
29 notice, this list of conditions and the following disclaimer in the
30 documentation and/or other materials provided with the distribution.
31
323. Neither the name(s) of the above-listed copyright holder(s) nor the
33 names of its contributors may be used to endorse or promote products
34 derived from this software without specific prior written permission.
35
36THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
37"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
40OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47
48
49
50Features
51--------
52
53Supported WPA/IEEE 802.11i features:
54- WPA-PSK ("WPA-Personal")
55- WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise")
56 Following authentication methods are supported with an integrate IEEE 802.1X
57 Supplicant:
58 * EAP-TLS
59 * EAP-PEAP/MSCHAPv2 (both PEAPv0 and PEAPv1)
60 * EAP-PEAP/TLS (both PEAPv0 and PEAPv1)
61 * EAP-PEAP/GTC (both PEAPv0 and PEAPv1)
62 * EAP-PEAP/OTP (both PEAPv0 and PEAPv1)
63 * EAP-PEAP/MD5-Challenge (both PEAPv0 and PEAPv1)
64 * EAP-TTLS/EAP-MD5-Challenge
65 * EAP-TTLS/EAP-GTC
66 * EAP-TTLS/EAP-OTP
67 * EAP-TTLS/EAP-MSCHAPv2
68 * EAP-TTLS/EAP-TLS
69 * EAP-TTLS/MSCHAPv2
70 * EAP-TTLS/MSCHAP
71 * EAP-TTLS/PAP
72 * EAP-TTLS/CHAP
73 * EAP-SIM
74 * EAP-AKA
Dmitry Shmidt9c175262016-03-03 10:20:07 -080075 * EAP-AKA'
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070076 * EAP-PSK
77 * EAP-PAX
78 * EAP-SAKE
79 * EAP-IKEv2
80 * EAP-GPSK
Dmitry Shmidt9c175262016-03-03 10:20:07 -080081 * EAP-pwd
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070082 * LEAP (note: requires special support from the driver for IEEE 802.11
83 authentication)
84 (following methods are supported, but since they do not generate keying
85 material, they cannot be used with WPA or IEEE 802.1X WEP keying)
86 * EAP-MD5-Challenge
87 * EAP-MSCHAPv2
88 * EAP-GTC
89 * EAP-OTP
90- key management for CCMP, TKIP, WEP104, WEP40
91- RSN/WPA2 (IEEE 802.11i)
92 * pre-authentication
93 * PMKSA caching
94
95Supported TLS/crypto libraries:
96- OpenSSL (default)
97- GnuTLS
98
99Internal TLS/crypto implementation (optional):
100- can be used in place of an external TLS/crypto library
101- TLSv1
102- X.509 certificate processing
103- PKCS #1
104- ASN.1
105- RSA
106- bignum
107- minimal size (ca. 50 kB binary, parts of which are already needed for WPA;
108 TLSv1/X.509/ASN.1/RSA/bignum parts are about 25 kB on x86)
109
110
111Requirements
112------------
113
114Current hardware/software requirements:
115- Linux kernel 2.4.x or 2.6.x with Linux Wireless Extensions v15 or newer
116- FreeBSD 6-CURRENT
117- NetBSD-current
118- Microsoft Windows with WinPcap (at least WinXP, may work with other versions)
119- drivers:
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700120 Linux drivers that support cfg80211/nl80211. Even though there are
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700121 number of driver specific interface included in wpa_supplicant, please
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700122 note that Linux drivers are moving to use generic wireless configuration
123 interface driver_nl80211 (-Dnl80211 on wpa_supplicant command line)
124 should be the default option to start with before falling back to driver
125 specific interface.
126
127 Linux drivers that support WPA/WPA2 configuration with the generic
128 Linux wireless extensions (WE-18 or newer). Obsoleted by nl80211.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700129
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700130 In theory, any driver that supports Linux wireless extensions can be
131 used with IEEE 802.1X (i.e., not WPA) when using ap_scan=0 option in
132 configuration file.
133
134 Wired Ethernet drivers (with ap_scan=0)
135
136 BSD net80211 layer (e.g., Atheros driver)
137 At the moment, this is for FreeBSD 6-CURRENT branch and NetBSD-current.
138
139 Windows NDIS
140 The current Windows port requires WinPcap (http://winpcap.polito.it/).
141 See README-Windows.txt for more information.
142
143wpa_supplicant was designed to be portable for different drivers and
144operating systems. Hopefully, support for more wlan cards and OSes will be
145added in the future. See developer's documentation
146(http://hostap.epitest.fi/wpa_supplicant/devel/) for more information about the
147design of wpa_supplicant and porting to other drivers. One main goal
148is to add full WPA/WPA2 support to Linux wireless extensions to allow
149new drivers to be supported without having to implement new
150driver-specific interface code in wpa_supplicant.
151
152Optional libraries for layer2 packet processing:
153- libpcap (tested with 0.7.2, most relatively recent versions assumed to work,
154 this is likely to be available with most distributions,
155 http://tcpdump.org/)
156- libdnet (tested with v1.4, most versions assumed to work,
157 http://libdnet.sourceforge.net/)
158
159These libraries are _not_ used in the default Linux build. Instead,
160internal Linux specific implementation is used. libpcap/libdnet are
161more portable and they can be used by adding CONFIG_L2_PACKET=pcap into
162.config. They may also be selected automatically for other operating
163systems. In case of Windows builds, WinPcap is used by default
164(CONFIG_L2_PACKET=winpcap).
165
166
167Optional libraries for EAP-TLS, EAP-PEAP, and EAP-TTLS:
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800168- OpenSSL (tested with 1.0.1 and 1.0.2 versions; assumed to
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700169 work with most relatively recent versions; this is likely to be
170 available with most distributions, http://www.openssl.org/)
171- GnuTLS
172- internal TLSv1 implementation
173
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700174One of these libraries is needed when EAP-TLS, EAP-PEAP, EAP-TTLS, or
175EAP-FAST support is enabled. WPA-PSK mode does not require this or EAPOL/EAP
176implementation. A configuration file, .config, for compilation is
177needed to enable IEEE 802.1X/EAPOL and EAP methods. Note that EAP-MD5,
178EAP-GTC, EAP-OTP, and EAP-MSCHAPV2 cannot be used alone with WPA, so
179they should only be enabled if testing the EAPOL/EAP state
180machines. However, there can be used as inner authentication
181algorithms with EAP-PEAP and EAP-TTLS.
182
183See Building and installing section below for more detailed
184information about the wpa_supplicant build time configuration.
185
186
187
188WPA
189---
190
191The original security mechanism of IEEE 802.11 standard was not
192designed to be strong and has proven to be insufficient for most
193networks that require some kind of security. Task group I (Security)
194of IEEE 802.11 working group (http://www.ieee802.org/11/) has worked
195to address the flaws of the base standard and has in practice
196completed its work in May 2004. The IEEE 802.11i amendment to the IEEE
197802.11 standard was approved in June 2004 and published in July 2004.
198
199Wi-Fi Alliance (http://www.wi-fi.org/) used a draft version of the
200IEEE 802.11i work (draft 3.0) to define a subset of the security
201enhancements that can be implemented with existing wlan hardware. This
202is called Wi-Fi Protected Access<TM> (WPA). This has now become a
203mandatory component of interoperability testing and certification done
204by Wi-Fi Alliance. Wi-Fi provides information about WPA at its web
205site (http://www.wi-fi.org/OpenSection/protected_access.asp).
206
207IEEE 802.11 standard defined wired equivalent privacy (WEP) algorithm
208for protecting wireless networks. WEP uses RC4 with 40-bit keys,
20924-bit initialization vector (IV), and CRC32 to protect against packet
210forgery. All these choices have proven to be insufficient: key space is
211too small against current attacks, RC4 key scheduling is insufficient
212(beginning of the pseudorandom stream should be skipped), IV space is
213too small and IV reuse makes attacks easier, there is no replay
214protection, and non-keyed authentication does not protect against bit
215flipping packet data.
216
217WPA is an intermediate solution for the security issues. It uses
218Temporal Key Integrity Protocol (TKIP) to replace WEP. TKIP is a
219compromise on strong security and possibility to use existing
220hardware. It still uses RC4 for the encryption like WEP, but with
221per-packet RC4 keys. In addition, it implements replay protection,
222keyed packet authentication mechanism (Michael MIC).
223
224Keys can be managed using two different mechanisms. WPA can either use
225an external authentication server (e.g., RADIUS) and EAP just like
226IEEE 802.1X is using or pre-shared keys without need for additional
227servers. Wi-Fi calls these "WPA-Enterprise" and "WPA-Personal",
228respectively. Both mechanisms will generate a master session key for
229the Authenticator (AP) and Supplicant (client station).
230
231WPA implements a new key handshake (4-Way Handshake and Group Key
232Handshake) for generating and exchanging data encryption keys between
233the Authenticator and Supplicant. This handshake is also used to
234verify that both Authenticator and Supplicant know the master session
235key. These handshakes are identical regardless of the selected key
236management mechanism (only the method for generating master session
237key changes).
238
239
240
241IEEE 802.11i / WPA2
242-------------------
243
244The design for parts of IEEE 802.11i that were not included in WPA has
245finished (May 2004) and this amendment to IEEE 802.11 was approved in
246June 2004. Wi-Fi Alliance is using the final IEEE 802.11i as a new
247version of WPA called WPA2. This includes, e.g., support for more
248robust encryption algorithm (CCMP: AES in Counter mode with CBC-MAC)
249to replace TKIP and optimizations for handoff (reduced number of
250messages in initial key handshake, pre-authentication, and PMKSA caching).
251
252
253
254wpa_supplicant
255--------------
256
257wpa_supplicant is an implementation of the WPA Supplicant component,
258i.e., the part that runs in the client stations. It implements WPA key
259negotiation with a WPA Authenticator and EAP authentication with
260Authentication Server. In addition, it controls the roaming and IEEE
261802.11 authentication/association of the wlan driver.
262
263wpa_supplicant is designed to be a "daemon" program that runs in the
264background and acts as the backend component controlling the wireless
265connection. wpa_supplicant supports separate frontend programs and an
266example text-based frontend, wpa_cli, is included with wpa_supplicant.
267
268Following steps are used when associating with an AP using WPA:
269
270- wpa_supplicant requests the kernel driver to scan neighboring BSSes
271- wpa_supplicant selects a BSS based on its configuration
272- wpa_supplicant requests the kernel driver to associate with the chosen
273 BSS
274- If WPA-EAP: integrated IEEE 802.1X Supplicant completes EAP
275 authentication with the authentication server (proxied by the
276 Authenticator in the AP)
277- If WPA-EAP: master key is received from the IEEE 802.1X Supplicant
278- If WPA-PSK: wpa_supplicant uses PSK as the master session key
279- wpa_supplicant completes WPA 4-Way Handshake and Group Key Handshake
280 with the Authenticator (AP)
281- wpa_supplicant configures encryption keys for unicast and broadcast
282- normal data packets can be transmitted and received
283
284
285
286Building and installing
287-----------------------
288
289In order to be able to build wpa_supplicant, you will first need to
290select which parts of it will be included. This is done by creating a
291build time configuration file, .config, in the wpa_supplicant root
292directory. Configuration options are text lines using following
293format: CONFIG_<option>=y. Lines starting with # are considered
294comments and are ignored. See defconfig file for an example configuration
295and a list of available options and additional notes.
296
297The build time configuration can be used to select only the needed
298features and limit the binary size and requirements for external
299libraries. The main configuration parts are the selection of which
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800300driver interfaces (e.g., nl80211, wext, ..) and which authentication
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700301methods (e.g., EAP-TLS, EAP-PEAP, ..) are included.
302
303Following build time configuration options are used to control IEEE
304802.1X/EAPOL and EAP state machines and all EAP methods. Including
305TLS, PEAP, or TTLS will require linking wpa_supplicant with OpenSSL
306library for TLS implementation. Alternatively, GnuTLS or the internal
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800307TLSv1 implementation can be used for TLS functionality.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700308
309CONFIG_IEEE8021X_EAPOL=y
310CONFIG_EAP_MD5=y
311CONFIG_EAP_MSCHAPV2=y
312CONFIG_EAP_TLS=y
313CONFIG_EAP_PEAP=y
314CONFIG_EAP_TTLS=y
315CONFIG_EAP_GTC=y
316CONFIG_EAP_OTP=y
317CONFIG_EAP_SIM=y
318CONFIG_EAP_AKA=y
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800319CONFIG_EAP_AKA_PRIME=y
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700320CONFIG_EAP_PSK=y
321CONFIG_EAP_SAKE=y
322CONFIG_EAP_GPSK=y
323CONFIG_EAP_PAX=y
324CONFIG_EAP_LEAP=y
325CONFIG_EAP_IKEV2=y
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800326CONFIG_EAP_PWD=y
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700327
328Following option can be used to include GSM SIM/USIM interface for GSM/UMTS
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800329authentication algorithm (for EAP-SIM/EAP-AKA/EAP-AKA'). This requires pcsc-lite
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700330(http://www.linuxnet.com/) for smart card access.
331
332CONFIG_PCSC=y
333
334Following options can be added to .config to select which driver
335interfaces are included.
336
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800337CONFIG_DRIVER_NL80211=y
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700338CONFIG_DRIVER_WEXT=y
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700339CONFIG_DRIVER_BSD=y
340CONFIG_DRIVER_NDIS=y
341
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800342Following example includes some more features and driver interfaces that
343are included in the wpa_supplicant package:
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700344
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800345CONFIG_DRIVER_NL80211=y
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700346CONFIG_DRIVER_WEXT=y
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700347CONFIG_DRIVER_BSD=y
348CONFIG_DRIVER_NDIS=y
349CONFIG_IEEE8021X_EAPOL=y
350CONFIG_EAP_MD5=y
351CONFIG_EAP_MSCHAPV2=y
352CONFIG_EAP_TLS=y
353CONFIG_EAP_PEAP=y
354CONFIG_EAP_TTLS=y
355CONFIG_EAP_GTC=y
356CONFIG_EAP_OTP=y
357CONFIG_EAP_SIM=y
358CONFIG_EAP_AKA=y
359CONFIG_EAP_PSK=y
360CONFIG_EAP_SAKE=y
361CONFIG_EAP_GPSK=y
362CONFIG_EAP_PAX=y
363CONFIG_EAP_LEAP=y
364CONFIG_EAP_IKEV2=y
365CONFIG_PCSC=y
366
367EAP-PEAP and EAP-TTLS will automatically include configured EAP
368methods (MD5, OTP, GTC, MSCHAPV2) for inner authentication selection.
369
370
371After you have created a configuration file, you can build
372wpa_supplicant and wpa_cli with 'make' command. You may then install
373the binaries to a suitable system directory, e.g., /usr/local/bin.
374
375Example commands:
376
377# build wpa_supplicant and wpa_cli
378make
379# install binaries (this may need root privileges)
380cp wpa_cli wpa_supplicant /usr/local/bin
381
382
383You will need to make a configuration file, e.g.,
384/etc/wpa_supplicant.conf, with network configuration for the networks
385you are going to use. Configuration file section below includes
386explanation fo the configuration file format and includes various
387examples. Once the configuration is ready, you can test whether the
388configuration work by first running wpa_supplicant with following
389command to start it on foreground with debugging enabled:
390
391wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -d
392
393Assuming everything goes fine, you can start using following command
394to start wpa_supplicant on background without debugging:
395
396wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
397
398Please note that if you included more than one driver interface in the
399build time configuration (.config), you may need to specify which
400interface to use by including -D<driver name> option on the command
401line. See following section for more details on command line options
402for wpa_supplicant.
403
404
405
406Command line options
407--------------------
408
409usage:
Dmitry Shmidtb97e4282016-02-08 10:16:07 -0800410 wpa_supplicant [-BddfhKLqqtuvW] [-P<pid file>] [-g<global ctrl>] \
Dmitry Shmidtb6e9aaf2013-05-20 14:49:44 -0700411 [-G<group>] \
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700412 -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
413 [-b<br_ifname> [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
Dmitry Shmidt2ac5f602014-03-07 10:08:21 -0800414 [-p<driver_param>] [-b<br_ifname>] [-m<P2P Device config file>] ...
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700415
416options:
417 -b = optional bridge interface name
418 -B = run daemon in the background
419 -c = Configuration file
420 -C = ctrl_interface parameter (only used if -c is not)
421 -i = interface name
422 -d = increase debugging verbosity (-dd even more)
423 -D = driver name (can be multiple drivers: nl80211,wext)
424 -f = Log output to default log location (normally /tmp)
425 -g = global ctrl_interface
Dmitry Shmidtb6e9aaf2013-05-20 14:49:44 -0700426 -G = global ctrl_interface group
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700427 -K = include keys (passwords, etc.) in debug output
428 -t = include timestamp in debug messages
429 -h = show this help text
Dmitry Shmidt04949592012-07-19 12:16:46 -0700430 -L = show license (BSD)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700431 -p = driver parameters
432 -P = PID file
433 -q = decrease debugging verbosity (-qq even less)
434 -u = enable DBus control interface
435 -v = show version
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700436 -W = wait for a control interface monitor before starting
437 -N = start describing new interface
Dmitry Shmidt2ac5f602014-03-07 10:08:21 -0800438 -m = Configuration file for the P2P Device
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700439
440drivers:
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700441 nl80211 = Linux nl80211/cfg80211
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700442 wext = Linux wireless extensions (generic)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700443 wired = wpa_supplicant wired Ethernet driver
444 roboswitch = wpa_supplicant Broadcom switch driver
445 bsd = BSD 802.11 support (Atheros, etc.)
446 ndis = Windows NDIS driver
447
448In most common cases, wpa_supplicant is started with
449
450wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
451
452This makes the process fork into background.
453
454The easiest way to debug problems, and to get debug log for bug
455reports, is to start wpa_supplicant on foreground with debugging
456enabled:
457
458wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d
459
460If the specific driver wrapper is not known beforehand, it is possible
461to specify multiple comma separated driver wrappers on the command
462line. wpa_supplicant will use the first driver wrapper that is able to
463initialize the interface.
464
465wpa_supplicant -Dnl80211,wext -c/etc/wpa_supplicant.conf -iwlan0
466
467
468wpa_supplicant can control multiple interfaces (radios) either by
469running one process for each interface separately or by running just
470one process and list of options at command line. Each interface is
471separated with -N argument. As an example, following command would
472start wpa_supplicant for two interfaces:
473
474wpa_supplicant \
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800475 -c wpa1.conf -i wlan0 -D nl80211 -N \
476 -c wpa2.conf -i wlan1 -D wext
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700477
478
479If the interface is added in a Linux bridge (e.g., br0), the bridge
480interface needs to be configured to wpa_supplicant in addition to the
481main interface:
482
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700483wpa_supplicant -cw.conf -Dnl80211 -iwlan0 -bbr0
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700484
485
486Configuration file
487------------------
488
489wpa_supplicant is configured using a text file that lists all accepted
490networks and security policies, including pre-shared keys. See
491example configuration file, wpa_supplicant.conf, for detailed
492information about the configuration format and supported fields.
493
494Changes to configuration file can be reloaded be sending SIGHUP signal
495to wpa_supplicant ('killall -HUP wpa_supplicant'). Similarly,
496reloading can be triggered with 'wpa_cli reconfigure' command.
497
498Configuration file can include one or more network blocks, e.g., one
499for each used SSID. wpa_supplicant will automatically select the best
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800500network based on the order of network blocks in the configuration
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700501file, network security level (WPA/WPA2 is preferred), and signal
502strength.
503
504Example configuration files for some common configurations:
505
5061) WPA-Personal (PSK) as home network and WPA-Enterprise with EAP-TLS as work
507 network
508
509# allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
510ctrl_interface=/var/run/wpa_supplicant
511ctrl_interface_group=wheel
512#
513# home network; allow all valid ciphers
514network={
515 ssid="home"
516 scan_ssid=1
517 key_mgmt=WPA-PSK
518 psk="very secret passphrase"
519}
520#
521# work network; use EAP-TLS with WPA; allow only CCMP and TKIP ciphers
522network={
523 ssid="work"
524 scan_ssid=1
525 key_mgmt=WPA-EAP
526 pairwise=CCMP TKIP
527 group=CCMP TKIP
528 eap=TLS
529 identity="user@example.com"
530 ca_cert="/etc/cert/ca.pem"
531 client_cert="/etc/cert/user.pem"
532 private_key="/etc/cert/user.prv"
533 private_key_passwd="password"
534}
535
536
5372) WPA-RADIUS/EAP-PEAP/MSCHAPv2 with RADIUS servers that use old peaplabel
538 (e.g., Funk Odyssey and SBR, Meetinghouse Aegis, Interlink RAD-Series)
539
540ctrl_interface=/var/run/wpa_supplicant
541ctrl_interface_group=wheel
542network={
543 ssid="example"
544 scan_ssid=1
545 key_mgmt=WPA-EAP
546 eap=PEAP
547 identity="user@example.com"
548 password="foobar"
549 ca_cert="/etc/cert/ca.pem"
550 phase1="peaplabel=0"
551 phase2="auth=MSCHAPV2"
552}
553
554
5553) EAP-TTLS/EAP-MD5-Challenge configuration with anonymous identity for the
556 unencrypted use. Real identity is sent only within an encrypted TLS tunnel.
557
558ctrl_interface=/var/run/wpa_supplicant
559ctrl_interface_group=wheel
560network={
561 ssid="example"
562 scan_ssid=1
563 key_mgmt=WPA-EAP
564 eap=TTLS
565 identity="user@example.com"
566 anonymous_identity="anonymous@example.com"
567 password="foobar"
568 ca_cert="/etc/cert/ca.pem"
569 phase2="auth=MD5"
570}
571
572
5734) IEEE 802.1X (i.e., no WPA) with dynamic WEP keys (require both unicast and
574 broadcast); use EAP-TLS for authentication
575
576ctrl_interface=/var/run/wpa_supplicant
577ctrl_interface_group=wheel
578network={
579 ssid="1x-test"
580 scan_ssid=1
581 key_mgmt=IEEE8021X
582 eap=TLS
583 identity="user@example.com"
584 ca_cert="/etc/cert/ca.pem"
585 client_cert="/etc/cert/user.pem"
586 private_key="/etc/cert/user.prv"
587 private_key_passwd="password"
588 eapol_flags=3
589}
590
591
5925) Catch all example that allows more or less all configuration modes. The
593 configuration options are used based on what security policy is used in the
594 selected SSID. This is mostly for testing and is not recommended for normal
595 use.
596
597ctrl_interface=/var/run/wpa_supplicant
598ctrl_interface_group=wheel
599network={
600 ssid="example"
601 scan_ssid=1
602 key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
603 pairwise=CCMP TKIP
604 group=CCMP TKIP WEP104 WEP40
605 psk="very secret passphrase"
606 eap=TTLS PEAP TLS
607 identity="user@example.com"
608 password="foobar"
609 ca_cert="/etc/cert/ca.pem"
610 client_cert="/etc/cert/user.pem"
611 private_key="/etc/cert/user.prv"
612 private_key_passwd="password"
613 phase1="peaplabel=0"
614 ca_cert2="/etc/cert/ca2.pem"
615 client_cert2="/etc/cer/user.pem"
616 private_key2="/etc/cer/user.prv"
617 private_key2_passwd="password"
618}
619
620
6216) Authentication for wired Ethernet. This can be used with 'wired' or
622 'roboswitch' interface (-Dwired or -Droboswitch on command line).
623
624ctrl_interface=/var/run/wpa_supplicant
625ctrl_interface_group=wheel
626ap_scan=0
627network={
628 key_mgmt=IEEE8021X
629 eap=MD5
630 identity="user"
631 password="password"
632 eapol_flags=0
633}
634
635
636
637Certificates
638------------
639
640Some EAP authentication methods require use of certificates. EAP-TLS
641uses both server side and client certificates whereas EAP-PEAP and
642EAP-TTLS only require the server side certificate. When client
643certificate is used, a matching private key file has to also be
644included in configuration. If the private key uses a passphrase, this
645has to be configured in wpa_supplicant.conf ("private_key_passwd").
646
647wpa_supplicant supports X.509 certificates in PEM and DER
648formats. User certificate and private key can be included in the same
649file.
650
651If the user certificate and private key is received in PKCS#12/PFX
652format, they need to be converted to suitable PEM/DER format for
653wpa_supplicant. This can be done, e.g., with following commands:
654
655# convert client certificate and private key to PEM format
656openssl pkcs12 -in example.pfx -out user.pem -clcerts
657# convert CA certificate (if included in PFX file) to PEM format
658openssl pkcs12 -in example.pfx -out ca.pem -cacerts -nokeys
659
660
661
662wpa_cli
663-------
664
665wpa_cli is a text-based frontend program for interacting with
666wpa_supplicant. It is used to query current status, change
667configuration, trigger events, and request interactive user input.
668
669wpa_cli can show the current authentication status, selected security
670mode, dot11 and dot1x MIBs, etc. In addition, it can configure some
671variables like EAPOL state machine parameters and trigger events like
672reassociation and IEEE 802.1X logoff/logon. wpa_cli provides a user
673interface to request authentication information, like username and
674password, if these are not included in the configuration. This can be
675used to implement, e.g., one-time-passwords or generic token card
676authentication where the authentication is based on a
677challenge-response that uses an external device for generating the
678response.
679
680The control interface of wpa_supplicant can be configured to allow
681non-root user access (ctrl_interface_group in the configuration
682file). This makes it possible to run wpa_cli with a normal user
683account.
684
685wpa_cli supports two modes: interactive and command line. Both modes
686share the same command set and the main difference is in interactive
687mode providing access to unsolicited messages (event messages,
688username/password requests).
689
690Interactive mode is started when wpa_cli is executed without including
691the command as a command line parameter. Commands are then entered on
692the wpa_cli prompt. In command line mode, the same commands are
693entered as command line arguments for wpa_cli.
694
695
696Interactive authentication parameters request
697
698When wpa_supplicant need authentication parameters, like username and
699password, which are not present in the configuration file, it sends a
700request message to all attached frontend programs, e.g., wpa_cli in
701interactive mode. wpa_cli shows these requests with
702"CTRL-REQ-<type>-<id>:<text>" prefix. <type> is IDENTITY, PASSWORD, or
703OTP (one-time-password). <id> is a unique identifier for the current
704network. <text> is description of the request. In case of OTP request,
705it includes the challenge from the authentication server.
706
707The reply to these requests can be given with 'identity', 'password',
708and 'otp' commands. <id> needs to be copied from the the matching
709request. 'password' and 'otp' commands can be used regardless of
710whether the request was for PASSWORD or OTP. The main difference
711between these two commands is that values given with 'password' are
712remembered as long as wpa_supplicant is running whereas values given
713with 'otp' are used only once and then forgotten, i.e., wpa_supplicant
714will ask frontend for a new value for every use. This can be used to
715implement one-time-password lists and generic token card -based
716authentication.
717
718Example request for password and a matching reply:
719
720CTRL-REQ-PASSWORD-1:Password needed for SSID foobar
721> password 1 mysecretpassword
722
723Example request for generic token card challenge-response:
724
725CTRL-REQ-OTP-2:Challenge 1235663 needed for SSID foobar
726> otp 2 9876
727
728
729wpa_cli commands
730
731 status = get current WPA/EAPOL/EAP status
732 mib = get MIB variables (dot1x, dot11)
733 help = show this usage help
734 interface [ifname] = show interfaces/select interface
735 level <debug level> = change debug level
736 license = show full wpa_cli license
737 logoff = IEEE 802.1X EAPOL state machine logoff
738 logon = IEEE 802.1X EAPOL state machine logon
739 set = set variables (shows list of variables when run without arguments)
740 pmksa = show PMKSA cache
741 reassociate = force reassociation
742 reconfigure = force wpa_supplicant to re-read its configuration file
743 preauthenticate <BSSID> = force preauthentication
744 identity <network id> <identity> = configure identity for an SSID
745 password <network id> <password> = configure password for an SSID
746 pin <network id> <pin> = configure pin for an SSID
747 otp <network id> <password> = configure one-time-password for an SSID
748 passphrase <network id> <passphrase> = configure private key passphrase
749 for an SSID
750 bssid <network id> <BSSID> = set preferred BSSID for an SSID
751 list_networks = list configured networks
752 select_network <network id> = select a network (disable others)
753 enable_network <network id> = enable a network
754 disable_network <network id> = disable a network
755 add_network = add a network
756 remove_network <network id> = remove a network
757 set_network <network id> <variable> <value> = set network variables (shows
758 list of variables when run without arguments)
759 get_network <network id> <variable> = get network variables
760 save_config = save the current configuration
761 disconnect = disconnect and wait for reassociate command before connecting
762 scan = request new BSS scan
763 scan_results = get latest scan results
764 get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> = get capabilies
765 terminate = terminate wpa_supplicant
766 quit = exit wpa_cli
767
768
769wpa_cli command line options
770
771wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] [-a<action file>] \
772 [-P<pid file>] [-g<global ctrl>] [command..]
773 -h = help (show this usage text)
774 -v = shown version information
775 -a = run in daemon mode executing the action file based on events from
776 wpa_supplicant
777 -B = run a daemon in the background
778 default path: /var/run/wpa_supplicant
779 default interface: first interface found in socket path
780
781
782Using wpa_cli to run external program on connect/disconnect
783-----------------------------------------------------------
784
785wpa_cli can used to run external programs whenever wpa_supplicant
786connects or disconnects from a network. This can be used, e.g., to
787update network configuration and/or trigget DHCP client to update IP
788addresses, etc.
789
790One wpa_cli process in "action" mode needs to be started for each
791interface. For example, the following command starts wpa_cli for the
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800792default interface (-i can be used to select the interface in case of
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700793more than one interface being used at the same time):
794
795wpa_cli -a/sbin/wpa_action.sh -B
796
797The action file (-a option, /sbin/wpa_action.sh in this example) will
798be executed whenever wpa_supplicant completes authentication (connect
799event) or detects disconnection). The action script will be called
800with two command line arguments: interface name and event (CONNECTED
801or DISCONNECTED). If the action script needs to get more information
802about the current network, it can use 'wpa_cli status' to query
803wpa_supplicant for more information.
804
805Following example can be used as a simple template for an action
806script:
807
808#!/bin/sh
809
810IFNAME=$1
811CMD=$2
812
813if [ "$CMD" = "CONNECTED" ]; then
814 SSID=`wpa_cli -i$IFNAME status | grep ^ssid= | cut -f2- -d=`
815 # configure network, signal DHCP client, etc.
816fi
817
818if [ "$CMD" = "DISCONNECTED" ]; then
819 # remove network configuration, if needed
820 SSID=
821fi
822
823
824
825Integrating with pcmcia-cs/cardmgr scripts
826------------------------------------------
827
828wpa_supplicant needs to be running when using a wireless network with
829WPA. It can be started either from system startup scripts or from
830pcmcia-cs/cardmgr scripts (when using PC Cards). WPA handshake must be
831completed before data frames can be exchanged, so wpa_supplicant
832should be started before DHCP client.
833
834For example, following small changes to pcmcia-cs scripts can be used
835to enable WPA support:
836
837Add MODE="Managed" and WPA="y" to the network scheme in
838/etc/pcmcia/wireless.opts.
839
840Add the following block to the end of 'start' action handler in
841/etc/pcmcia/wireless:
842
843 if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
844 /usr/local/bin/wpa_supplicant -B -c/etc/wpa_supplicant.conf \
845 -i$DEVICE
846 fi
847
848Add the following block to the end of 'stop' action handler (may need
849to be separated from other actions) in /etc/pcmcia/wireless:
850
851 if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
852 killall wpa_supplicant
853 fi
854
855This will make cardmgr start wpa_supplicant when the card is plugged
856in.
857
858
859
860Dynamic interface add and operation without configuration files
861---------------------------------------------------------------
862
863wpa_supplicant can be started without any configuration files or
864network interfaces. When used in this way, a global (i.e., per
865wpa_supplicant process) control interface is used to add and remove
866network interfaces. Each network interface can then be configured
867through a per-network interface control interface. For example,
868following commands show how to start wpa_supplicant without any
869network interfaces and then add a network interface and configure a
870network (SSID):
871
872# Start wpa_supplicant in the background
873wpa_supplicant -g/var/run/wpa_supplicant-global -B
874
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700875# Add a new interface (wlan0, no configuration file, driver=nl80211, and
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700876# enable control interface)
877wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan0 \
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700878 "" nl80211 /var/run/wpa_supplicant
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700879
880# Configure a network using the newly added network interface:
881wpa_cli -iwlan0 add_network
882wpa_cli -iwlan0 set_network 0 ssid '"test"'
883wpa_cli -iwlan0 set_network 0 key_mgmt WPA-PSK
884wpa_cli -iwlan0 set_network 0 psk '"12345678"'
885wpa_cli -iwlan0 set_network 0 pairwise TKIP
886wpa_cli -iwlan0 set_network 0 group TKIP
887wpa_cli -iwlan0 set_network 0 proto WPA
888wpa_cli -iwlan0 enable_network 0
889
890# At this point, the new network interface should start trying to associate
891# with the WPA-PSK network using SSID test.
892
893# Remove network interface
894wpa_cli -g/var/run/wpa_supplicant-global interface_remove wlan0
895
896
897Privilege separation
898--------------------
899
900To minimize the size of code that needs to be run with root privileges
901(e.g., to control wireless interface operation), wpa_supplicant
902supports optional privilege separation. If enabled, this separates the
903privileged operations into a separate process (wpa_priv) while leaving
904rest of the code (e.g., EAP authentication and WPA handshakes) into an
905unprivileged process (wpa_supplicant) that can be run as non-root
906user. Privilege separation restricts the effects of potential software
907errors by containing the majority of the code in an unprivileged
908process to avoid full system compromise.
909
910Privilege separation is not enabled by default and it can be enabled
911by adding CONFIG_PRIVSEP=y to the build configuration (.config). When
912enabled, the privileged operations (driver wrapper and l2_packet) are
913linked into a separate daemon program, wpa_priv. The unprivileged
914program, wpa_supplicant, will be built with a special driver/l2_packet
915wrappers that communicate with the privileged wpa_priv process to
916perform the needed operations. wpa_priv can control what privileged
917are allowed.
918
919wpa_priv needs to be run with network admin privileges (usually, root
920user). It opens a UNIX domain socket for each interface that is
921included on the command line; any other interface will be off limits
922for wpa_supplicant in this kind of configuration. After this,
923wpa_supplicant can be run as a non-root user (e.g., all standard users
924on a laptop or as a special non-privileged user account created just
925for this purpose to limit access to user files even further).
926
927
928Example configuration:
929- create user group for users that are allowed to use wpa_supplicant
930 ('wpapriv' in this example) and assign users that should be able to
931 use wpa_supplicant into that group
932- create /var/run/wpa_priv directory for UNIX domain sockets and control
933 user access by setting it accessible only for the wpapriv group:
934 mkdir /var/run/wpa_priv
935 chown root:wpapriv /var/run/wpa_priv
936 chmod 0750 /var/run/wpa_priv
937- start wpa_priv as root (e.g., from system startup scripts) with the
938 enabled interfaces configured on the command line:
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700939 wpa_priv -B -P /var/run/wpa_priv.pid nl80211:wlan0
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700940- run wpa_supplicant as non-root with a user that is in wpapriv group:
941 wpa_supplicant -i ath0 -c wpa_supplicant.conf
942
943wpa_priv does not use the network interface before wpa_supplicant is
944started, so it is fine to include network interfaces that are not
945available at the time wpa_priv is started. As an alternative, wpa_priv
946can be started when an interface is added (hotplug/udev/etc. scripts).
947wpa_priv can control multiple interface with one process, but it is
948also possible to run multiple wpa_priv processes at the same time, if
949desired.
Dmitry Shmidt56052862013-10-04 10:23:25 -0700950
951
952Linux capabilities instead of privileged process
953------------------------------------------------
954
955wpa_supplicant performs operations that need special permissions, e.g.,
956to control the network connection. Traditionally this has been achieved
957by running wpa_supplicant as a privileged process with effective user id
9580 (root). Linux capabilities can be used to provide restricted set of
959capabilities to match the functions needed by wpa_supplicant. The
960minimum set of capabilities needed for the operations is CAP_NET_ADMIN
961and CAP_NET_RAW.
962
963setcap(8) can be used to set file capabilities. For example:
964
965sudo setcap cap_net_raw,cap_net_admin+ep wpa_supplicant
966
967Please note that this would give anyone being able to run that
968wpa_supplicant binary access to the additional capabilities. This can
969further be limited by file owner/group and mode bits. For example:
970
971sudo chown wpas wpa_supplicant
972sudo chmod 0100 wpa_supplicant
973
974This combination of setcap, chown, and chmod commands would allow wpas
975user to execute wpa_supplicant with additional network admin/raw
976capabilities.
977
978Common way style of creating a control interface socket in
979/var/run/wpa_supplicant could not be done by this user, but this
980directory could be created before starting the wpa_supplicant and set to
981suitable mode to allow wpa_supplicant to create sockets
982there. Alternatively, other directory or abstract socket namespace could
983be used for the control interface.
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800984
985
986External requests for radio control
987-----------------------------------
988
989External programs can request wpa_supplicant to not start offchannel
990operations during other tasks that may need exclusive control of the
991radio. The RADIO_WORK control interface command can be used for this.
992
993"RADIO_WORK add <name> [freq=<MHz>] [timeout=<seconds>]" command can be
994used to reserve a slot for radio access. If freq is specified, other
995radio work items on the same channel may be completed in
996parallel. Otherwise, all other radio work items are blocked during
997execution. Timeout is set to 10 seconds by default to avoid blocking
998wpa_supplicant operations for excessive time. If a longer (or shorter)
999safety timeout is needed, that can be specified with the optional
1000timeout parameter. This command returns an identifier for the radio work
1001item.
1002
1003Once the radio work item has been started, "EXT-RADIO-WORK-START <id>"
1004event message is indicated that the external processing can start. Once
1005the operation has been completed, "RADIO_WORK done <id>" is used to
1006indicate that to wpa_supplicant. This allows other radio works to be
1007performed. If this command is forgotten (e.g., due to the external
Dmitry Shmidt9c175262016-03-03 10:20:07 -08001008program terminating), wpa_supplicant will time out the radio work item
1009and send "EXT-RADIO-WORK-TIMEOUT <id>" event to indicate that this has
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001010happened. "RADIO_WORK done <id>" can also be used to cancel items that
1011have not yet been started.
1012
1013For example, in wpa_cli interactive mode:
1014
1015> radio_work add test
10161
1017<3>EXT-RADIO-WORK-START 1
1018> radio_work show
1019ext:test@wlan0:0:1:2.487797
1020> radio_work done 1
1021OK
1022> radio_work show
1023
1024
1025> radio_work done 3
1026OK
1027> radio_work show
1028ext:test freq=2412 timeout=30@wlan0:2412:1:28.583483
1029<3>EXT-RADIO-WORK-TIMEOUT 2
1030
1031
1032> radio_work add test2 freq=2412 timeout=60
10335
1034<3>EXT-RADIO-WORK-START 5
1035> radio_work add test3
10366
1037> radio_work add test4
10387
1039> radio_work show
1040ext:test2 freq=2412 timeout=60@wlan0:2412:1:9.751844
1041ext:test3@wlan0:0:0:5.071812
1042ext:test4@wlan0:0:0:3.143870
1043> radio_work done 6
1044OK
1045> radio_work show
1046ext:test2 freq=2412 timeout=60@wlan0:2412:1:16.287869
1047ext:test4@wlan0:0:0:9.679895
1048> radio_work done 5
1049OK
1050<3>EXT-RADIO-WORK-START 7
1051<3>EXT-RADIO-WORK-TIMEOUT 7