如何强制gradle信任maven中央仓库?

问题描述 投票:0回答:2

尝试使用 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

所有人都有同样的问题。

我也尝试过:

  1. 手动导入repo.maven.apache.org证书到lib/security/cacerts。

  2. mavenCentral()
    替换为

     maven {
        url "https://repo.maven.apache.org/maven2/"
        allowInsecureProtocol = true
     }
    
  3. 在conf/security/java.security

    中较新的JDK上从
    SSLv3, TLSv1, TLSv1.1
    中删除了
    jdk.tls.disabledAlgorithms

还有什么可以尝试的?

gradle tls1.2 java-11 tls1.3
2个回答
1
投票

有点捂脸。我的

build.gradle
有以下几行:

System.setProperty("javax.net.ssl.trustStore", "my-keystore.jks")
System.setProperty("javax.net.ssl.trustStorePassword", "s3cret")

其中包含过期证书。


0
投票

我也遇到了同样的问题,最后根据gradle文档解决了问题,在

https.protocols
中添加了
gradle.properties

https.protocols=TLSv1.1,TLSv1.2,TLSv1.3
© www.soinside.com 2019 - 2024. All rights reserved.