README 38 KB

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