自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
首次使用時信任 (TOFU)
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
對於搭載 Android 13 以上版本的裝置,Android 支援「首次使用即信任」(TOFU) 驗證方法 (RFC7435),讓使用者安裝伺服器使用的根 CA,並在已儲存的網路中設定其網域名稱,藉此信任企業 (EAP) 網路。在使用者首次連線至企業網路時,TOFU 可讓裝置取得未經驗證的公開金鑰,並保留該金鑰供後續連線使用。
背景
與只需要密碼的個人網路相比,企業網路會使用公開金鑰基礎架構 (PKI) 驗證,這需要用戶端預先安裝憑證。在 Android 11 以下版本中,使用者可以在網路設定中為伺服器 CA 憑證選取「Do not validate」選項,藉此略過伺服器端憑證的驗證程序。不過,為了強化安全性並遵守 WPA R2 規格,Android 12 規定企業網路必須進行伺服器憑證驗證。這項額外規定會對使用者造成障礙,因為他們必須為這類網路安裝 CA 憑證。TOFU 提供一種方法,讓使用者只要接受根 CA,就能連線至以 PKI 為基礎的企業網路。
功能行為
當使用者連線至沒有已安裝已驗證的公開金鑰的企業網路時,支援 TOFU 的裝置會顯示以下行為。
透過 Wi-Fi 挑選器連線至新的網路
在 Wi-Fi 挑選器中選取新的企業網路。
裝置會顯示對話方塊 (圖 1),確認網路是否可信任。
輕觸「是,連線」接受網路連線,或輕觸「否,不連線」拒絕。
圖 1. TOFU 功能的對話方塊
連線至已啟用自動連線功能的現有網路
當裝置連線至已啟用自動連線功能但沒有有效 CA 憑證的企業網路時,裝置會自動連線,然後顯示固定 (無法關閉) 的通知。
輕觸通知。
裝置會顯示對話方塊 (圖 1),確認網路是否可信任。
輕觸「是,連線」接受網路連線,或輕觸「否,不連線」拒絕。
實作
如要支援 TOFU 功能,請在 /hardware/interfaces/wifi/supplicant/aidl/android/hardware/wifi/supplicant
中實作 Android 開放原始碼計畫 (AOSP) 提供的申請者 HAL。
以下公用 API 可供 Android 13 應用程式使用:
驗證
如要驗證裝置上的 TOFU 導入作業,請使用下列測試:
- CTS:
CtsWifiTestCases
- VTS:
VtsHalWifiSupplicantStaNetworkTargetTest
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Trust on First Use (TOFU)\n\nFor devices running Android 13 or higher, Android\nsupports the Trust on First Use (TOFU) authentication approach\n([RFC7435](https://datatracker.ietf.org/doc/html/rfc7435.html)),\nwhich lets users trust an enterprise (EAP) network by installing the root CA\nused by the server and setting its domain name in a saved network. TOFU allows\nthe device to obtain an unauthenticated public key when a user first connects\nto an enterprise network and retain the key for subsequent connections.\n\nBackground\n----------\n\nCompared to personal networks that just require a password, enterprise networks\nuse public key infrastructure (PKI) authentication, which requires the client\nto preinstall certificates. In Android 11 or lower, users can select the\n*Do not validate* option for the server CA certificate in the network settings,\nbypassing the validation of the server side certificate. However, to strengthen\nsecurity and comply with the WPA R2 specification, Android 12 introduced a\nrequirement for enterprise networks to have server certificate validation. This\nadditional requirement created a barrier for users as they need to install a CA\ncertificate for such networks. TOFU provides a way for users to connect to a\nPKI-based enterprise network by simply accepting its root CA.\n\nFeature behavior\n----------------\n\nDevices that support TOFU display the following behavior when a user connects\nto an enterprise network that doesn't have an *already-installed*\nauthenticated public key.\n\n### Connect to new network through Wi-Fi picker\n\n1. Select a new enterprise network in Wi-Fi picker.\n\n The device displays a dialog (Figure 1) to confirm whether the\n network is trusted.\n2. Tap **Yes, connect** to accept the network connection, or tap **No, don't\n connect** to decline.\n\n - If you tap **Yes, connect**, the device automatically configures the\n security parameters, connects to the network, and enables autoconnect\n for the network.\n\n | **Note:** Misconfigured networks that use invalid or expired certificates might not allow any security validation by the device. In such cases, the device fails to connect to the network.\n - If you tap **No, don't connect**, the device disconnects from the\n network and disables autoconnect for the network.\n\n **Figure 1.** Dialog for the TOFU feature\n\n### Connect to existing network with autoconnect enabled\n\nWhen connecting to an enterprise network that has autoconnect enabled but\ndoesn't have a valid CA certificate, the device connects automatically, then\ndisplays a sticky (nondismissable) notification.\n\n1. Tap the notification.\n\n The device displays a dialog (Figure 1) to confirm whether the\n network is trusted.\n2. Tap **Yes, connect** to accept the network connection, or tap **No, don't\n connect** to decline.\n\n - If you tap **Yes, connect**, the device automatically configures the\n security parameters, connects to the network, and enables autoconnect\n for the network.\n\n | **Note:** Misconfigured networks that use invalid or expired certificates might not allow any security validation by the device. In such cases, the device fails to connect to the network.\n - If you tap **No, don't connect**, the device disconnects from the\n network and disables autoconnect for the network.\n\nImplementation\n--------------\n\nTo support the TOFU feature, implement the supplicant HALs provided in the\nAndroid Open Source Project (AOSP) at\n[`/hardware/interfaces/wifi/supplicant/aidl/android/hardware/wifi/supplicant`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/wifi/supplicant/aidl/android/hardware/wifi/supplicant).\n\nThe following public APIs are available in Android 13\nfor use by apps:\n\n- [`WifiManager#isTrustOnFirstUseSupported()`](https://developer.android.com/reference/android/net/wifi/WifiManager#isTrustOnFirstUseSupported()): Indicates whether the device supports TOFU.\n- [`WifiEnterpriseConfig#enableTrustOnFirstUse(boolean)`](https://developer.android.com/reference/android/net/wifi/WifiEnterpriseConfig#enableTrustOnFirstUse(boolean)): Enables TOFU.\n- [`WifiEnterpriseConfig#isTrustOnFirstUseEnabled()`](https://developer.android.com/reference/android/net/wifi/WifiEnterpriseConfig#isTrustOnFirstUseEnabled()): Indicates whether TOFU is enabled.\n\nValidation\n----------\n\nTo validate the implementation of TOFU on your device, use the following tests:\n\n- CTS: `CtsWifiTestCases`\n- VTS: `VtsHalWifiSupplicantStaNetworkTargetTest`"]]