我将项目的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
PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException: cannot to find valid certification path to requested target
当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 my-alias -file my-company.crt
以下解决方案对我有效。我刚刚禁用了TLS
在gradle的Repositories部分:
将mavenCentral()
替换为
maven {
url = "http://repo.maven.apache.org/maven2"
allowInsecureProtocol = true
}
和jcenter()
with
maven {
url = "http://jcenter.bintray.com"
allowInsecureProtocol = true
}
和任何其他存储库只需使用HTTP协议的url,而不是HTTPS,并确保设置allowInsecureProtocol = true
在我的情况下,这个错误是由于我的互联网服务提供商使用自定义CA证书来拦截和过滤我的SSL流量。
一旦我用正确的CA证书链连接到互联网,构建就完成了,没有错误。
指出:
-
此错误可能是由于您的互联网连接上的SSL证书/CA问题。
-
一旦构建完成,一切都很好,直到构建需要下载新的gradle版本。