尽管安装了证书,Gradle构建仍因sun.security.validator.ValidatorException而失败

w6lpcovy  于 2022-11-30  发布在  其他
关注(0)|答案(2)|浏览(282)

我尝试根据他们的指令运行lenskit-hello。当我运行./gradlew build时,我收到错误

(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莫哈韦10.14.6上使用的是Java 1.8.0_241(而且只安装了这一个)。我已经安装了最新的安全更新,然后重新启动了我的电脑。我已经在我的常规WiFi和手机的热点上尝试了这一点。
我按照已接受答案here中的说明,从https://repo1.maven.org/maven2/org/lenskit/lenskit-all/3.0-M2/lenskit-all-3.0-M2.pomhttps://oss.sonatype.org/content/repositories/snapshots/org/lenskit/lenskit-all/3.0-M2/lenskit-all-3.0-M2.pom下载安全证书,并通过以下命令将它们添加到密钥库中(仅显示两个中的一个):

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时仍然得到同样的错误?
我还检查了openssl x509 -in /Users/briennakh/Downloads/maven.pem -text以确保证书看起来正常。

yacmzcpb

yacmzcpb1#

SSL certificate不是自签名开始,因此不需要手动添加。请尝试重新安装Java或将备用安装位置设置为$JAVA_HOME,并使用默认的cacerts文件。某些内容似乎已损坏,因为它不应该拒绝repo1.maven.org的证书。ls -la $JAVA_HOME/jre/lib/security/cacerts表示cacerts应该有大约114757个字节。
这将尝试SSL会话(不通过Java):

$ openssl s_client -connect repo1.maven.org:443

该项目还使用了相当过时的Gradle版本,例如:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
eblbsuwk

eblbsuwk2#

这可能是网络相关的问题。我也遇到过同样的问题。我总是使用公司的VPN,而Gradle建设。所以,然后我尝试没有VPN它给我上面的错误。但改变连接到VPN,问题得到解决。检查Gradle sync failed: Cause: unable to find valid certification path to requested target on MacOS

相关问题