自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
Conscrypt
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Conscrypt 模組可加快安全性改善作業,並改善裝置安全性,不必仰賴 OTA 更新。它會使用 Java 程式碼和原生程式庫,提供 Android TLS 實作,以及大部分的 Android 密碼編譯功能,例如金鑰產生器、密碼和訊息摘要。Conscrypt 可做為開放原始碼程式庫使用,但在 Android 平台中加入時,它會具備一些專門功能。
Conscrypt 模組會使用 BoringSSL,這是 Google 分支自 OpenSSL 的本機程式庫,用於許多 Google 產品的加密編譯和傳輸層安全標準 (TLS) (最著名的是 Google Chrome),並與 Conscrypt 程式碼 (Java 和本機程式碼) 搭配使用。BoringSSL 沒有正式版本 (所有使用者都從最新版本建構),也不保證 API 或 ABI 的穩定性。
Android 15 的變更
Android 15 限制 TLS 1.0 和 1.1 版本的使用。這些版本先前已在 Android 中淘汰,但現在已禁止用於指定 Android 15 為目標版本的應用程式。
Android 14 的變更
Android 14 在 Conscrypt 中推出可更新的根信任存放區。CA 憑證 (或憑證) 為 Android 和網際網路中使用的公開金鑰提供信任根。系統會定期檢查這些憑證,確保加密簽署正確無誤,因此必須在所有依賴這些憑證的裝置上提供及儲存這些憑證。
在 Mainline 之前,Android 會將憑證儲存在系統分區 (在 system/ca-certificates
中),並在每次 Android 版本更新時更新憑證。有了 Mainline,您可以使用 Mainline 火車更新功能,更頻繁地更新憑證。這項新功能應可簡化更新程序,讓我們更快解決問題,並延長裝置的使用壽命。
自 Android 14 起,根信任憑證會儲存在 Conscrypt 模組 APEX 和系統分區中。應用程式仍可自行選擇憑證,並使用 NetworkSecurityConfig
修改憑證行為。
Android 14 包含以下其他 Conscrypt 模組變更:
- 新增 AES-CMAC MAC 實作。
- 已淘汰並移除 `PBEwithHmacSHA2-*` MAC 實作。
- 新增了對 X25519 金鑰、金鑰協議和簽章的有限支援。
- 更新 BoringSSL 以確保 X.509 正確性。
- 在公開的 CertPath API 中,已停止支援 MD5 簽署的憑證。自 API 級別 16 起,這類憑證就不再適用於 TLS 連線。
Android 10 的變更
Android 9 並未納入專屬於 Conscrypt 的 Android 公開 API,而是使用安全性提供者,為 Java Cryptography Architecture (JCA) 實作標準類別,包括 Cipher 和 MessageDigest,以及 Java Secure Socket Extension (JSSE),包括 SSLSocket 和 SSLEngine。使用者會與這些類別互動,而 libcore
或架構程式碼會使用部分非公開的 Conscrypt API。
Android 10 在 android.net.ssl
中新增了少數公開 API 方法,用於存取 javax.net.ssl
下方類別未公開的 Conscrypt 功能。Android 10 也包含 Bouncy Castle 的簡化副本,可在 Android 執行階段提供較不受歡迎的加密工具 (不包含在 Conscrypt 模組中)。
Conscrypt 模組 (com.android.conscrypt
) 會以 APEX 檔案形式發行,其中包含 Conscrypt Java 程式碼和 Conscrypt 原生程式庫,可動態連結至 Android NDK 程式庫 (例如 liblog
)。原生程式庫也包含 BoringSSL 副本,該副本已通過 NIST 的加密編譯資料庫驗證計畫 (CMVP) 驗證 (憑證 #3753)。
Conscrypt 模組會公開下列 API:
- 公用 API 是
java.*
和 javax.*
下套件中的類別和介面擴充功能,以及 android.net.ssl.*
下類別的擴充功能。外部應用程式程式碼不會直接呼叫 Conscrypt。平台 API 標準可確保這些 API 維持回溯和前向相容性。
- 核心平台 API 是架構用來存取非公開功能的隱藏 API。這些元件相對較少;最大的使用者是
NetworkSecurityConfig
,它會擴充 Conscrypt 信任管理工具 (用於驗證憑證的元件),以實作網路安全性設定功能。
- 核心內 API僅限於由 JCA 和 JSEE 機制以反射方式呼叫的零引數建構函式。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# Conscrypt\n\nThe Conscrypt module accelerates security improvements and improves device\nsecurity without relying on OTA updates. It uses Java code and a native\nlibrary to provide the Android TLS implementation as well as a large portion\nof Android cryptographic functionality such as key generators, ciphers, and\nmessage digests. Conscrypt is available as an\n[open source\nlibrary](https://github.com/google/conscrypt), though it has some specializations when included in the Android\nplatform.\n\n\nThe Conscrypt module uses\n[BoringSSL](https://boringssl.googlesource.com/boringssl/),\na native library that is a Google fork of OpenSSL and which is used in many\nGoogle products for cryptography and TLS (most notably Google Chrome), in conjunction with\nConscrypt code (both Java and native code). BoringSSL doesn't have official releases (all users\nbuild from head) and makes no guarantees around API or ABI stability.\n\nChanges in Android 15\n---------------------\n\n\nAndroid 15 restricts the usage of TLS versions 1.0 and 1.1. These versions\nhad previously been deprecated in Android, but are now disallowed for apps targeting Android\n15.\n\nChanges in Android 14\n---------------------\n\n\nAndroid 14 introduces an updatable root trust store within Conscrypt. CA\ncertificates (or certs) provide the roots of trust for public keys used within Android and the\ninternet at large. These certificates are routinely checked to ensure proper cryptographic signing,\nso they must be provided and stored on all devices that rely on them.\n\n\nPrior to Mainline, Android stored certificates in the system partition (in\n`system/ca-certificates`) and updated them with every Android release. Now with Mainline,\nit's possible to update certificates more frequently using Mainline train updates. This new\ncapability should streamline updating processes, allow us to have faster turnaround times for\nissues, and help to extend device lifetimes.\n\n\nStarting in Android 14, root trust certificates are stored in the Conscrypt\nmodule APEX and the system partition. Apps can still choose their own certificates and modify\ncertificate behavior using `NetworkSecurityConfig`.\n\nAndroid 14 includes these other Conscrypt module changes:\n\n- Added AES-CMAC MAC implementation.\n- Deprecated and removed \\`PBEwithHmacSHA2-\\*\\` MAC implementations.\n- Added limited support for X25519 keys, key agreements, and signatures.\n- Updated BoringSSL for X.509 correctness.\n- Dropped support for MD5-signed certificates in the public CertPath APIs. Such certificates haven't been accepted for TLS connections since API level 16.\n\nChanges in Android 10\n---------------------\n\n\nAndroid 9 doesn't include an Android-specific public API for Conscrypt but\ninstead uses a security provider that implements standard classes for Java\nCryptography Architecture (JCA) including Cipher and MessageDigest, and\nJava Secure Socket Extension (JSSE), including SSLSocket and SSLEngine.\nUsers interact with those classes and some nonpublic Conscrypt APIs are used\nby `libcore` or frameworks code.\n\n\nAndroid 10 adds a small number of public API methods\nin `android.net.ssl` to access Conscrypt functionality that isn't\nexposed by the classes under `javax.net.ssl`. Android\n10 also includes a slimmed copy of\n[Bouncy Castle](https://en.wikipedia.org/wiki/Bouncy_Castle_(cryptography)) to provide lower-popularity cryptographic\ntools as part of Android Runtime (not included in the Conscrypt module).\n\nFormat and dependencies\n-----------------------\n\nThe Conscrypt module (`com.android.conscrypt`) is distributed as an [APEX](/docs/core/ota/apex) file that\nincludes the Conscrypt Java code and a Conscrypt native library that dynamically\nlinks to Android NDK libraries (such as `liblog`). The native library\nalso includes a copy of BoringSSL that has has been validated ([Certificate #3753](https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/3753)) through NIST's [Cryptographic Module Validation Program (CMVP)](https://csrc.nist.gov/projects/cryptographic-module-validation-program).\n| **Note:** The Conscrypt module includes [/external/conscrypt](https://android.googlesource.com/platform/external/conscrypt/) and [/external/boringssl](https://android.googlesource.com/platform/external/boringssl/), but doesn't include `/external/bouncycastle`.\n\n\nThe Conscrypt module exposes the following APIs:\n\n- **Public APIs** are extensions of classes and interfaces in packages under `java.*` and `javax.*`, plus classes under `android.net.ssl.*`. External app code doesn't call Conscrypt directly. Platform API standards ensure that these APIs remain backward- and forward-compatible.\n- **Core platform APIs** are hidden APIs used by the framework to access nonpublic functionality. These are relatively limited; the largest user is `NetworkSecurityConfig`, which extends the Conscrypt trust manager (the component that verifies certificates) to implement the [network security configuration feature](https://developer.android.com/training/articles/security-config).\n- **Intra-core APIs** are limited to zero-argument constructors called reflectively by the JCA and JSEE machinery."]]