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

使用com.appmattus证书透明度库遇Google V2列表废弃404错误,如何解决?

解决Certificate Transparency库404错误的方案

核心原因

Google已停止支持v2版本的CT日志列表,原v2地址返回404,而你使用的com.appmattus.certificatetransparency库默认拉取该v2地址,导致加载失败。


具体解决办法

1. 升级库到最新稳定版

新版本的库已适配Google的v3日志列表地址,直接升级是最简便的方案。在你的Gradle依赖中替换为最新版本:

implementation 'com.appmattus.certificatetransparency:certificatetransparency:1.12.0'

(注:请确认使用Maven Central上的最新稳定版本)

2. 手动指定v3日志列表地址(适用于无法升级库的场景)

在初始化Certificate Transparency拦截器时,自定义日志列表的加载URL,指向Google的v3地址:

val ctInterceptor = CertificateTransparencyInterceptor.Builder()
    .logListDataSource(
        LogListDataSourceFactory.create(
            okHttpClient = OkHttpClient(),
            url = "https://www.gstatic.com/ct/log_list/v3/log_list.json"
        )
    )
    .build()

// 将拦截器添加到你的OkHttp客户端
val okHttpClient = OkHttpClient.Builder()
    .addInterceptor(ctInterceptor)
    .build()

3. 本地嵌入日志列表文件(避免网络依赖)

如果需要彻底避免网络加载失败的问题,可以将v3版本的log_list.json下载到本地,放入app的assets目录,然后从本地加载:

val ctInterceptor = CertificateTransparencyInterceptor.Builder()
    .logListDataSource(object : LogListDataSource {
        override suspend fun get(): LogList {
            val json = context.assets.open("log_list.json").bufferedReader().readText()
            return LogListMapper.map(json)
        }
    })
    .build()

注意:需要定期手动更新本地的log_list.json文件,以保持日志列表的时效性。


内容的提问来源于stack exchange,提问作者Parth Gupta

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 21:30:56