Gradle无法从HTTPS通过代理下载插件

时间:2017-02-24 22:23:37

标签: gradle proxy

我一直试图让我们下载一个来自HTTPS网址的插件,并且无法解决我的错误。从我在互联网上阅读的内容来看,这通常是通过设置代理来解决的 - 我已经从调试日志gradle中使用了它。我还尝试手动将调试日志中所有URL列出的证书添加到我的cacerts文件中无效。

调试日志 - 来自gradle为springboot插件执行的上一次重定向 - 如下所示:

Redirecting to 'https://jcenter.bintray.com/org/springframework/boot/spring-boot-tools/1.4.3.RELEASE/spring-boot-tools-1.4.3.RELEASE.pom' via {tls}->http://myProxy:2020->https://jcenter.bintray.com:443
can be kept alive indefinitely
Connection released: [id: 204][route: {tls}->http://myProxy:2020->https://plugins.gradle.org:443][total kept alive: 2; route allocated: 1 of 2; total allocated: 2 of 20]
CookieSpec selected: default
Auth cache not set in the context
Connection request: [route: {tls}->http://myProxy:2020->https://jcenter.bintray.com:443][total kept alive: 2; route allocated: 0 of 2; total allocated: 2 of 20]
Connection leased: [id: 206][route: {tls}->http://myProxy:2020->https://jcenter.bintray.com:443][total kept alive: 2; route allocated: 1 of 2; total allocated: 3 of 20]
Opening connection {tls}->http://myProxy:2020->https://jcenter.bintray.com:443
Connecting to myProxy/myProxyIp:2020
Connection established myIp:64916<->myProxyIp:2020
Tunnel to target created.
Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
Enabled cipher suites:[Removed for readability]
Starting handshake
http-outgoing-206: Shutdown connection
Connection discarded
http-outgoing-206: Close connection
Connection released: [id: 206][route: {tls}->http://myProxy:2020->https://jcenter.bintray.com:443][total kept alive: 2; route allocated: 0 of 2; total allocated: 2 of 20]
Flushing resolved configuration data in Binary store in C:\Temp\gradle7433380394459999850.bin. Wrote root 2.
Timing: Running the build script took 1.082 secs

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'TutorialHelloWorld'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE.
     Required by:
         project :
      > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE.
         > Could not parse POM https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/1.4.3.RELEASE/spring-boot-gradle-plugin-1.4.3.RELEASE.pom
            > Could not resolve org.springframework.boot:spring-boot-tools:1.4.3.RELEASE.
               > Could not resolve org.springframework.boot:spring-boot-tools:1.4.3.RELEASE.
                  > Could not get resource 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-tools/1.4.3.RELEASE/spring-boot-tools-1.4.3.RELEASE.pom'.
                     > Could not GET 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-tools/1.4.3.RELEASE/spring-boot-tools-1.4.3.RELEASE.pom'.
                        > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* Try:
Run with --stacktrace option to get the stack trace. 

BUILD FAILED

我可以通过浏览器下载此文件,该浏览器也使用代理,因此应该没问题。这是Java 1.8.0_71-b15和gradle 3.4。

我也尝试从没有代理的网络上的同一台机器上执行相同的命令(并且没有为gradle配置代理)并最终得到相同的错误,所以看起来这是我的环境而不是代理。

有什么想法可以在这里发生什么?

2 个答案:

答案 0 :(得分:0)

我在上次编辑后最终重新启动了机器,现在gradle build命令似乎工作正常;我不确定重新启动会发生什么变化,或者它是否会保持这种状态,但至少现在它似乎正在起作用。

答案 1 :(得分:0)

我没有根,这对我有帮助

export JAVA_TOOL_OPTIONS+="-Djava.net.useSystemProxies=true -Djavax.net.ssl.trustStore=$HOME/jks/cacerts"
keytool -import -alias root_ca -trustcacerts -keystore $HOME/jks/cacerts -file /tmp/root-ca.pem
keytool -import -alias sub_ca -trustcacerts -keystore $HOME/jks/cacerts -file /tmp/sub-ca.pem