SSLContext.init throws NoClassDefFoundError on Android API 21-23 in 2.10.0

未关闭
#1,573 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
49/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
android, java
领域
backend, security

调研方向

Start with SSLParametersImpl.unwrapTrustManager and getNetworkSecurityPolicyMethod, named in the stack trace, then inspect the new ConscryptEngineSocket$DelegatingTrustManager and the Android API level where its superclass became available. Reproduce with the linked API 21–23 project and compare behavior with 2.9.0. Done means SSLContext.init works on API 21–23 while retaining the intended security fix.

由索引模型根据 Issue 内容生成。

描述

SSLContext.init throws NoClassDefFoundError on Android API 21-23 in 2.10.0

Version: org.conscrypt:conscrypt-android:2.10.0 (2.9.0 works)
Affected: Android API 21-23 (tested on API 23, the class it needs arrived in API 24). Works on API 28.

Background

We support some older Android devices running API 21+. We use Conscrypt to improve their TLS support.

Problem

With 2.10.0, every SSLContext.init on the Conscrypt provider fails on API 21-23:

java.lang.NoClassDefFoundError: org.conscrypt.ConscryptEngineSocket$DelegatingTrustManager
at org.conscrypt.SSLParametersImpl.unwrapTrustManager(SSLParametersImpl.java:265)
at org.conscrypt.SSLParametersImpl.getNetworkSecurityPolicyMethod(SSLParametersImpl.java:272)
at org.conscrypt.SSLParametersImpl.<init>(SSLParametersImpl.java:174)
at org.conscrypt.OpenSSLContextImpl.engineInit(OpenSSLContextImpl.java:115)
at javax.net.ssl.SSLContext.init(SSLContext.java:349)

The first call reports Failed resolution of: Lorg/conscrypt/ConscryptEngineSocket$DelegatingTrustManager;.

Cause

ConscryptEngineSocket$DelegatingTrustManager, new in 2.10.0, extends javax.net.ssl.X509ExtendedTrustManager. Android added that class in API 24. SSLParametersImpl.<init> reaches it through getNetworkSecurityPolicyMethod → unwrapTrustManager on every init, whichever trust managers are passed, so the class can't be resolved on older devices. The AAR still declares minSdkVersion 21.

Reproduction

https://github.com/jordanbd/conscrypt-api23-repro

SSLContext context = SSLContext.getInstance("TLS", Conscrypt.newProvider());
context.init(null, null, null); // NoClassDefFoundError on API 21-23
Device 2.9.0 2.10.0
API 23 emulator (6.0) 4/4 pass 3/4 fail, NoClassDefFoundError
rk3288_box device (5.1.1, API 22) 4/4 pass 3/4 fail, NoClassDefFoundError
API 28 emulator (9) 4/4 pass 4/4 pass
Impact

Apps with minSdk below 24 that use Conscrypt for modern TLS can't create a Conscrypt SSLContext on those devices after upgrading. That leaves them stuck on 2.9.0, which is inside the affected range of the 2.10.0 security fix (GHSA-h3wp-2gww-26c4).

Whilst GHSA-h3wp-2gww-26c4 does not affect our usage of Conscrypt I would prefer to be able to patch if I can.

I have reviewed the release notes and can't see where the min SDK was bumped, so I was wondering if this was intentional? Android 21 is ridiculously old, so I understand if the library is moving on.

主要语言
Java
星标
1.4k
派生
332
平均合并
2 天 56 分钟
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

google/conscrypt 的其他 Issue

查看 google/conscrypt 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。