Downloading https://services.gradle.org/distributions/gradle-2.12-bin.zip
Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
类似的问题:
gradlew. bat(和gradlew)SSLHandShakeException
除了我只有在通过包装器执行时才得到这个异常?(安装的本地gradle命令没有任何问题。)我尝试了建议的解决方案,只是无法让它工作。我甚至在cacerts中下载并安装了https://services.gradle.org/distributions/的证书
keytool -import -file "C:\tmp\gradlew.x509.base64.cer" -alias gradle -keystore "C:\Apps\java\jre\lib\security\cacerts"
我从包装器得到了命令:
java -Dorg.gradle.appname=gradlew -classpath "C:\mystuff\gradle-2.12\samples\java\multiproject\\gradle\wrapper\gradle-wrapper.jar" org.gradle.wrapper.GradleWrapperMain clean
我的猜测是证书本身可能有问题,或者我使用了错误的编码?
$ java -version
Picked up _JAVA_OPTIONS: -Xmx512M
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
为了使此复杂化,我尝试使用此处建议的方法从gradle安装证书,该方法似乎有效(根据输出)
http://infposs.blogspot.ca/2013/06/installcert-and-java-7.html
但是当我运行包装器时,我仍然得到相同的错误。
我对SSL证书了解不多,但我注意到,当我尝试为上面的url安装cert时,实际上返回了2个证书…仔细查看InstallCert.java中的java代码,我注意到它只安装(天真地?)第一个证书。
我在InstallCert.java中更改了代码(添加了一个for循环),并安装了证书和gradle,java很高兴交换握手,从此以后每个人都过着幸福的生活。
这是我改的密码
for (int i = 0; i < chain.length; i++) {
final X509Certificate cert = chain[i];
final String alias = host + "-" + (i + 1);
ks.setCertificateEntry(alias, cert);
final OutputStream out = new FileOutputStream(file);
ks.store(out, passphrase);
out.close();
System.out.println();
System.out.println(cert);
System.out.println();
System.out.println(
"Added certificate to keystore 'cacerts' using alias '"
+ alias + "'");
}
它位于调用实际keystore方法的main函数的末尾。
因此,如果您对InstallCert.java进行上述修改,解决方案非常简单:
javac InstallCert.java
java InstallCert services.gradle.org
顺便说一下,导致我调查此途径的原因是,当我针对旧版本的java(我认为是1.6)运行客户端时,它会吐出以下错误:
java.security.cert.CertPathValidatorException: The certificate issued by ... is not trusted; internal cause is:
java.security.cert.CertPathValidatorException: Certificate chaining error