尽管安装了证书,但由于 sun.security.validator.ValidatorException 导致 Gradle 构建失败 [英] Gradle build fails due to sun.security.validator.ValidatorException despite installing certificates
问题描述
我正在尝试根据他们的说明运行 lenskit-hello.当我运行 ./gradlew build
时,我收到错误
I'm trying to run lenskit-hello according to their instructions. When I run ./gradlew build
, I receive the error
(base) Briennas-MBP:lenskit-hello-master briennakh$ ./gradlew build
:compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not resolve org.lenskit:lenskit-all:3.0-M3.
Required by:
:lenskit-hello-master 4.50.57 AM:unspecified
> Could not resolve org.lenskit:lenskit-all:3.0-M3.
> Could not get resource 'https://repo1.maven.org/maven2/org/lenskit/lenskit-all/3.0-M3/lenskit-all-3.0-M3.pom'.
> Could not GET 'https://repo1.maven.org/maven2/org/lenskit/lenskit-all/3.0-M3/lenskit-all-3.0-M3.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve org.lenskit:lenskit-all:3.0-M3.
> Could not get resource 'https://jcenter.bintray.com/org/lenskit/lenskit-all/3.0-M3/lenskit-all-3.0-M3.pom'.
> Could not GET 'https://jcenter.bintray.com/org/lenskit/lenskit-all/3.0-M3/lenskit-all-3.0-M3.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. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.009 secs
我在 MacOS Mojave 10.14.6 上使用 Java 1.8.0_241(并且只安装了那个).我已经安装了最新的安全更新,然后重新启动了我的计算机.我已经在我的常规 wifi 和我手机的热点上尝试过这个.
I am using Java 1.8.0_241 (and only that one is installed) on MacOS Mojave 10.14.6. I've installed the most recent security updates, then restarted my computer. I have attempted this on my regular wifi and on my phone's hotspot.
我按照接受的答案中的说明进行操作此处,从 https://repo1.maven.org/maven2/org/lenskit/lenskit-all/3.0-M2/lenskit-all-3.0-M2.pom
和 下载安全证书code>https://oss.sonatype.org/content/repositories/snapshots/org/lenskit/lenskit-all/3.0-M2/lenskit-all-3.0-M2.pom
并通过以下命令(仅显示两个之一):
I followed instructions in the accepted answer here, downloading the security certificates from both https://repo1.maven.org/maven2/org/lenskit/lenskit-all/3.0-M2/lenskit-all-3.0-M2.pom
and https://oss.sonatype.org/content/repositories/snapshots/org/lenskit/lenskit-all/3.0-M2/lenskit-all-3.0-M2.pom
and adding them to the keystore via the following command (only showing one of two):
keytool -import -alias maven -file /Users/briennakh/Downloads/maven.cer -keystore
/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/security/cacerts
然后如果我检查
keytool -list -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/security/cacerts | grep maven
它显示我的证书已添加,maven,Mar 17, 2020,trustedCertEntry
,但我在运行./gradlew build
时仍然遇到同样的错误?
it shows that my certificate has been added, maven, Mar 17, 2020, trustedCertEntry
, yet I'm still getting the same error when running ./gradlew build
?
我还检查了 openssl x509 -in/Users/briennakh/Downloads/maven.pem -text
以确保证书看起来没问题.
I also checked openssl x509 -in /Users/briennakh/Downloads/maven.pem -text
to make sure that the certificate looks all right.
推荐答案
SSL 证书 不是自签名的,因此不需要手动添加.尝试重新安装 Java 或将备用安装位置设置为 $JAVA_HOME
,并使用默认的 cacerts
文件.似乎有些问题,因为它不应该拒绝 repo1.maven.org
<的证书/a>.ls -la $JAVA_HOME/jre/lib/security/cacerts
说 cacerts
应该有大约 114757 个字节.如果您位于防火墙后面,则可能需要配置代理 用于 Gradle.
That SSL certificate is not self-signed to begin with, therefore it does not require manual adding. Try re-installing Java or set an alternate install location as $JAVA_HOME
, with a default cacerts
file. Something seems to be broken, as it should not reject the certificate for repo1.maven.org
. ls -la $JAVA_HOME/jre/lib/security/cacerts
says cacerts
should have about 114757 bytes. If you're behind a firewall, you might need to configure a proxy for Gradle.
这应该尝试 SSL 会话(不是通过 Java):
This should attempt an SSL session (not through Java):
$ openssl s_client -connect repo1.maven.org:443
<小时>
这个项目还使用了一个相当过时的 Gradle 版本,例如:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
这篇关于尽管安装了证书,但由于 sun.security.validator.ValidatorException 导致 Gradle 构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!