尝试使用 gradle 构建时出现此错误
./gradlew build
:
...
> Could not resolve org.apache.httpcomponents:httpcore:4.4.15.
> Could not get resource 'https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.4.15/httpcore-4.4.15.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.4.15/httpcore-4.4.15.pom'.
> The server may not support the client's requested TLS protocol versions: (SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.0.2/userguide/build_environment.html#gradle_system_properties
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
...
mavencentral 似乎不太可能不支持任何 TLS 协议。
这是我的 gradle.properties:
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Dhttps.protocols=SSLv3,TLSv1,TLSv1.1,TLSv1.2,TLSv1.3
org.gradle.java.home=/path/to/jdk-11.0.5+10
org.gradle.allow-insecure-protocol=true
systemProp.scan.uploadInBackground=false
我尝试过:
Gradle 版本 7.0.2 和 7.3.3
JVM 版本 OpenJDK 11.0.5+10、Oracle JDK 11.0.13 和 OpenJDK 11.0.14+9
所有人都有同样的问题。
我也尝试过:
手动导入repo.maven.apache.org证书到lib/security/cacerts。
将
mavenCentral()
替换为
maven {
url "https://repo.maven.apache.org/maven2/"
allowInsecureProtocol = true
}
在conf/security/java.security
中较新的JDK上从
SSLv3, TLSv1, TLSv1.1
中删除了
jdk.tls.disabledAlgorithms
还有什么可以尝试的?
有点捂脸。我的
build.gradle
有以下几行:
System.setProperty("javax.net.ssl.trustStore", "my-keystore.jks")
System.setProperty("javax.net.ssl.trustStorePassword", "s3cret")
其中包含过期证书。
我也遇到了同样的问题,最后根据gradle文档解决了问题,在
https.protocols
中添加了
gradle.properties
https.protocols=TLSv1.1,TLSv1.2,TLSv1.3