自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
Conscrypt
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助 Conscrypt 模块,无需依赖于 OTA 更新,即可加速实现安全改进并提高设备安全性。它使用 Java 代码和原生库来提供 Android TLS 实现以及大部分 Android 加密功能(例如密钥生成器、加密算法和消息摘要)。Conscrypt 以开源库的形式提供,但包含在 Android 平台中时有一些特殊化。
Conscrypt 模块使用 BoringSSL,后者是 Google 在 OpenSSL 基础上派生出的一个原生库,在很多 Google 产品(最值得注意的是 Google Chrome)中和 Conscrypt 代码(Java 代码和原生代码)一起用于加密和传输层安全协议 (TLS)。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 不包含 Android 特有的公共 Conscrypt API,而是使用一种安全提供程序。该安全提供程序可为 Java 加密架构 (JCA)(包括加密算法和消息摘要)和 Java 安全套接字扩展 (JSSE)(包括 SLSocket 和 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 代码以及一个动态链接到 Android NDK 库(如 liblog
)的 Conscrypt 原生库。该原生库还包含一个已通过 NIST 的加密模块验证计划 (CMVP) 进行验证(证书 #3753)的 BoringSSL 副本。
Conscrypt 模块公开以下 API:
- 公共 API 是
java.*
和 javax.*
下软件包中的类和接口以及 android.net.ssl.*
下的类的扩展。外部应用代码无法直接调用 Conscrypt。平台 API 标准确保这些 API 保持向后和向前兼容性。
- 核心平台 API 是框架访问非公开功能时使用的隐藏 API。这些 API 相对有限;最大的使用者是
NetworkSecurityConfig
,它扩展 Conscrypt 信任管理器(用于验证证书的组件)来实现网络安全配置功能。
- 核心内 API 仅限于由 JCA 和 JSEE 机制以反射方式调用的零参数构造函数。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):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"]],["最后更新时间 (UTC):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."]]