【问题标题】:How to resolve gradle tls connection after upgrading from 5.4 to 6.8.3?从 5.4 升级到 6.8.3 后如何解决 gradle tls 连接问题?
【发布时间】:2021-09-14 14:54:10
【问题描述】:

我将项目 Gradle 版本从 5.4.1 升级到 6.8.3,并将自定义存储库更改为 https。

我在 maven 上遇到了类似的问题,但在镜像解决之后。我可以使用 gradle 5.4.1 毫无问题地构建项目,但是当我将 gradle 升级到 6.8.3 时,出现以下错误:

        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

【问题讨论】:

  • 关于该问题的信息不足。我们需要有关该项目的全面信息。您正在使用 Docker 和容器。但是,您没有提供任何相关信息。运行时环境很重要,32 位或 64 位系统或软件很重要,JRE、JDK 如何容器化很重要。所以。请提供尽可能多的信息。谢谢

标签: java gradle java-8 android-gradle-plugin java-11


【解决方案1】:

PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效认证路径

当 JRE 缺少证书时,您会收到此消息。我认为您将不得不在 docker 映像的 JRE 中安装公司的证书

您的 Dockerfile 需要执行以下操作:

FROM adoptopenjdk/openjdk11:jre-11.0.11_9-alpine

// my-company.crt is your company's certificate
COPY my-company.crt my-company.crt

RUN keytool -cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias begoroot -file my-company.crt

【讨论】:

  • 感谢您的贡献!
  • 奇怪的是jdk8 我仍然遇到同样的问题。但是使用 JDK 11 就可以了
  • 我假设这是一个不同的 docker 镜像,你是否在两个镜像中都安装了证书?
  • 是的,我做了同样的步骤。唯一的区别是 jdk8 映像不运行带有 -cacerts 标志的 RUN keytool -cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias begoroot -file my-company.crt。我没有-cacerts就跑了。
  • 我认为使用 java 8 你需要使用-file $JAVA_HOME/lib/security/cacerts 而不是-cacerts
猜你喜欢
  • 1970-01-01
  • 2018-05-29
  • 2014-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-04
  • 2021-08-25
  • 2023-01-12
相关资源
最近更新 更多