You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android多机型(Android 5至14)使用DigiCert证书出现CertPathValidatorException信任锚缺失问题求助

Android多机型(Android 5至14)使用DigiCert证书出现CertPathValidatorException信任锚缺失问题求助

我目前遇到一个棘手的SSL信任问题,想请教下有没有同行碰到过类似情况,以及该怎么解决。

场景说明

  • 涉及印度地区的多款Android设备,系统版本覆盖Android 5到Android 14,总共上百种机型,其中前十款为:M2010J19SI、CPH2579、MT2111、SM-M315F、220733SI、CPH2139、CPH1933、EB2101、RMX3780
  • 后端服务器使用付费的DigiCert Global Root G2证书
  • 客户端通过OkHttp库发起网络请求

问题现象

这些特定设备无法连接服务器,错误统计系统捕获到的异常信息如下:

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

已做的尝试与验证

  1. 假设验证:推测设备系统信任列表中缺少目标根证书

    • 在设备/模拟器上手动禁用DigiCert根证书(模拟器路径:设置->安全->加密与凭据->受信任的凭据)
    • 发起请求后,抛出与线上完全一致的错误,验证了假设的合理性
  2. 嵌入证书到App的修复尝试:

    • 将digi_cert_global_cag2证书文件放入res/raw目录
    • 在res/xml目录下创建network_security_config.xml,内容如下:
      <?xml version="1.0" encoding="utf-8"?>
      <network-security-config>
        <base-config cleartextTrafficPermitted="false">
          <trust-anchors>
            <certificates src="@raw/digi_cert_global_cag2" />
            <certificates src="system" />
          </trust-anchors>
        </base-config>
      </network-security-config>
      
    • 在AndroidManifest.xml的application节点中配置该安全配置:
      <application
        android:networkSecurityConfig="@xml/network_security_config"
        ...
      
    • 模拟器上测试请求恢复正常,但线上问题设备仍持续抛出相同SSL错误

限制条件

  • 无法拿到能复现问题的实体设备,仅能通过模拟器模拟场景
  • 替换为Let's Encrypt证书不可行,第三方要求必须使用付费证书
  • 忽略该错误也不被允许,DevOps团队强烈反对

求助问题

  • 有没有同行碰到过这种嵌入证书后仍无法解决的信任锚缺失问题?
  • 针对这种情况,有没有可行的解决办法?

备注:内容来源于stack exchange,提问作者mohax

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 07:59:31