前陣子被朋友找去看無線網路 + RADIUS 上 WPA2 Enterprise 的問題,認證用的密碼是以 MD5 形式存在 LDAP,於是有人連 Wifi 時,走沒加密的 SSID 經過 controller 的網頁認證會過,但走 WPA2 就怎麼改設定都過不了。
挑選經由 RADIUS 作認證的協定,需視密碼的儲存方式而定。可參見 Deploying RADIUS: Protocol and Password Compatibility 密碼格式與認證協定的對應表。
從對應表來看,如果密碼資料庫不能提供明碼(或是用微軟的帳號或 AD),那麼可以採用的方案很少,只能想辦法讓用戶以安全的方式也把明碼丟回 RADIUS 作認證。這次遇到的例子,可考慮的有 EAP-GTC (包在 PEAPv0 或 EAP-TTLS 裡面) 與 EAP-TTLS-PAP (EAP-TTLS with inner PAP) 等等,其實都是建通道在裡頭跑 PAP 的作法,但在用戶端的支援度是有差別的,而且都沒有很廣泛的支援。
相關的參考資料,目前看起來就 eduroam 整理地最齊全。用戶端的相容性可參見 Devices that are compatible with eduroam (GÉANT federated confluence)。
這邊整理一下跑 EAP-GTC 與 EAP-TTLS with inner PAP 的筆記。
EAP-GTC
Generic Token Card (GTC) 是 Cisco 提出的 EAP Type,已收錄在 RFC 3748 Section 5.6,但由於 Cisco 並沒有推得很用力,用戶端的普及率並不高。
Windows 沒有內建支援 EAP-GTC,目前普遍看到的支援方式都是請大家去裝 Cisco Aironet 無線網卡的驅動程式、或是 Aruba 提供的函式庫。iOS 9 倒是不用特別設定,連到基地台的時候直接輸入帳號密碼即可。
由於 EAP-GTC 本身沒有加密,故考慮 PEAPv0/EAP-GTC 與 EAP-TTLS-GTC 兩種設定方式。(註:FreeRADIUS 只支援在 EAP-PEAPv0 與 EAP-TTLS 裡面跑 EAP-GTC)
下面是 FreeRADIUS 的部份設定,有省略一些原始範例就有的設定,使用上還請注意。
eap.conf
eap {
default_eap_type = peap # or "ttls" for EAP-TTLS-GTC
gtc {
auth_type = PAP
}
tls {
... # (ignored, see your eap.conf example)
}
ttls {
default_eap_type = gtc
copy_request_to_tunnel = no
use_tunneled_reply = no
virtual_server = "inner-tunnel"
}
peap {
default_eap_type = gtc
copy_request_to_tunnel = no
use_tunneled_reply = no
virtual_server = "inner-tunnel"
}
}
EAP-TTLS with inner PAP
在 Tunneled TLS 通道內跑 PAP 認證的作法,用戶端的支援比較複雜。
- Windows 8 / 8.1 / 10: 有支援,範例參見EAP-TTLS on Windows 8 (Build 8250) | Notes on IT (mainly Microsoft)。須事先在用戶端匯入憑證。
- Windows XP / Vista / 7: 沒有原生支援,許多機構建議加裝 SecureW2 EAP Suite 應對,但該軟體的新版本已經沒有免費授權了。
- Apple iOS: 須額外匯入設定檔或是 Helper App 做設定。以前有 iPhone Configuration Utility 可以產生 Wifi profile,但 Apple 已經在去年年初停止提供,我暫時沒有找到方便的設定方式。(註:eduroam 後來自己開發了 Configuration Assistant Tool 提供自家用戶作設定。)
以下是 FreeRADIUS 作 EAP-TTLS with inner PAP 的設定。須注意由於 EAP type 並沒有 pap, 故 ttls 的 default_eap_type 預設為 md5, 但實際上以本文 MD5 密碼存在 LDAP 的例子是無法做 EAP-TTLS-MD5 認證的。
eap.conf
eap {
default_eap_type = ttls
tls {
... # (ignored, see your eap.conf example)
}
ttls {
default_eap_type = md5
copy_request_to_tunnel = no
use_tunneled_reply = no
virtual_server = "inner-tunnel"
}
}
FreeRADIUS 的 virtual server 設定
sites-enabled/default 或是 radiusd.conf
authorize {
preprocess
chap
mschap
digest
suffix
eap {
ok = return
}
files
ldap
expiration
logintime
pap
}
authenticate {
Auth-Type PAP {
# 註:在此置入你的密碼認證模組,例如 ldap
ldap
}
Auth-Type CHAP {
chap
}
Auth-Type MS-CHAP {
mschap
}
digest
unix
eap
}
# ... (ignored, see your configuration examples)
post-proxy {
eap
}
sites-enabled/inner-tunnel 或是 radiusd.conf 的 server inner-tunnel { ... }
server inner-tunnel {
listen {
ipaddr = 127.0.0.1
port = 18120
type = auth
}
authorize {
chap
mschap
suffix
update control {
Proxy-To-Realm := LOCAL
}
eap {
ok = return
}
ldap
# 註:如果收到 User-Password 密碼欄,強制進行 LDAP 認證。(僅供參考)
if (User-Password) {
update control {
Auth-Type := LDAP
}
}
files
expiration
logintime
pap
}
authenticate {
Auth-Type PAP {
# 註:在此置入你的密碼認證模組,例如 ldap
ldap
}
Auth-Type CHAP {
chap
}
Auth-Type MS-CHAP {
mschap
}
unix
Auth-Type LDAP {
ldap
}
eap
}
# ... (ignored, see your configuration examples)
post-proxy {
eap
}
} # inner-tunnel server block
802.1x 測試方法
wpa_supplicant 有 eapol_test 工具可供測試。
Linux distribution 包的 wpa_supplicant 可能不會提供 eapol_test binary (Ubuntu 與 CentOS 都沒有),編譯指令如下:
wget http://w1.fi/releases/wpa_supplicant-2.5.tar.gz tar zxvf wpa_supplicant-2.5.tar.gz cd wpa_supplicant-2.5/wpa_supplicant cp defconfig .config make eapol_test
註:如果遇到 crypto_openssl.c:316: undefined reference 的編譯錯誤,改用舊版本的 wpa_supplicant 試試。
安裝完成後,準備 eapol_test 指令需要的設定檔。各種範例可參考 FreeRADIUS 的 test case。(對,是在 FreeRADIUS 的 source code 裡面,不是 wpa_supplicant。)
測試指令的格式:./eapol_test -c eap-foo.conf -s AS_secret
(eap-foo.conf 為設定檔名稱,AS_secret 為 RADIUS server 的 secret key。)
PEAPv0/EAP-GTC 的 eapol_test config
引用自 freeradius-server/src/tests/eapol_test/peap-eap-gtc.conf。
#
# ./eapol_test -c peap-eap-gtc.conf -s testing123
#
network={
ssid="example"
key_mgmt=WPA-EAP
eap=PEAP
identity="bob"
anonymous_identity="anonymous"
password="bob"
phase2="auth=GTC"
phase1="peapver=0"
}
EAP-TTLS-GTC 的 eapol_test config
引用自 freeradius-server/src/tests/eapol_test/ttls-eap-gtc.conf。
#
# eapol_test -c eap-ttls-eap-gtc.conf -s testing123
#
network={
key_mgmt=WPA-EAP
eap=TTLS
identity="bob"
anonymous_identity="anonymous"
ca_cert="raddb/certs/ca.pem"
password="bob"
phase2="autheap=GTC"
}
EAP-TTLS with inner PAP 的 eapol_test config
引用自 freeradius-server/src/tests/eapol_test/ttls-pap.conf。
#
# eapol_test -c ttls-pap.conf -s testing123
#
network={
key_mgmt=WPA-EAP
eap=TTLS
identity="bob"
anonymous_identity="anonymous"
#ca_cert="raddb/certs/ca.pem"
password="bob"
phase2="auth=PAP"
}
註:eapol_test 的設定檔參數可參考 wpa_supplicant.conf 範例中的註解。
憑證問題
FreeRADIUS server 使用的 X.509 範例憑證通常是放在 /etc/raddb/certs 而不是 /etc/pki 之類的地方。安全起見一定要重新簽過,參見 /etc/raddb/certs/README 的步驟重簽即可。
此外,FreeRADIUS Wiki 與 eduroam 的網站上也有提供較詳細的憑證相容性解說,可參照: