Gradle The server may not support the client's requested TLS protocol versions

4,530 阅读1分钟
  1. 背景:
  • 公司使用代理联网
  • Android Studio 需要配置 cacerts 文件 才可以联网
  • 最近开始尝试flutter 项目,但是依赖始终下载不了,显示下面的issue , 但是对应的链接放在浏览器可以联网
  1. 查找:
 The server may not support the client's requested TLS protocol versions: (TLSv1.2). You may need to configure the client to allow other protocols to be used.
     See: https://docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
                          > sun.security.validator.ValidatorException: 
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

How to resolve gradle tls connection after upgrading from 5.4 to 6.8.3

How to force gradle to trust maven central repo

Gradle 7.4 build with resolve error: The server may not support the client's requested TLS protocol versions

Maven repo errors while building a 2023 project on Windows

腾讯的镜像仓库不支持TLSv1.2, TLSv1.3,gradle构建报错

  • 找了好多不同的网站,主要处理方案有以下几种
    1. 将网站证书(cer文件)写入 cacerts 文件, --》试了不行
    2. 在gradle.properties 添加代理信息 systemProp.https.proxyPassword=pwd systemProp.https.proxyUser=username systemProp.https.proxyHost=host systemProp.https.proxyPort=port --> 配置了还是不行
    3. 更换代理 --> 做不到
  1. 感觉上既然使用浏览器可以访问,那么一定是cacerts 文件有什么问题限制了gradle的代理, 后面没想到在公司内网找了一片相关文章,里面提供了另外一个cacert文件,试了下居然可以。

  2. 本着探究本质的精神,把两个cacerts 的内容打出来看了看:

keytool -list -v -keystore <cacerts path> 
password: changeit

发现新的证书里公司发布的证书中的 AuthorityInfoAccess 包含一个根证书(root),而旧的没有,只有一个标准证书(Standard)。可能这是区别所在(还有其他区别,但是似乎看起来关系不大)。

  1. 总的来说,出现这种问题,多半是代理的问题,如果增加配置始终不行,只能找TI协助处理