反复收到“PKIX 路径构建失败”和“无法找到请求目标的有效证书路径”

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

我在

mvn clean install
执行期间一直面临这个烦人的证书问题。

PS C:\Users\milan\service> mvn clean install
[INFO] Scanning for projects...
Downloading from spring-milestones: https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/2.2.0.M6/spring-boot-starter-parent-2.2.0.M6.pom
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.2.0.M6/spring-boot-starter-parent-2.2.0.M6.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.demo.microservices:service:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.0.M6 from/to spring-milestones (https://repo.spring.io/milestone): transfer failed for https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/2.2.0.M6/spring-boot-starter-parent-2.2.0.M6.pom and 'parent.relativePath' points at no local POM @ line 4, column 11
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.demo.microservices:service:0.0.1-SNAPSHOT (C:\Users\milan\service\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for com.demo.microservices:service:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.0.M6 from/to spring-milestones (https://repo.spring.io/milestone): transfer failed for https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/2.2.0.M6/spring-boot-starter-parent-2.2.0.M6.pom and 'parent.relativePath' points at no local POM @ line 4, column 11: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

我找到了解决方案,效果很好。

有什么解决方案,可以一劳永逸地解决这个问题吗?

系统

Apache Maven 3.8.4 
Maven home: C:\apache-maven-3.8.4
Java version: 17.0.1, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-17.0.1.12-hotspot
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
java windows maven ssl-certificate
2个回答
1
投票

我可以通过替换

cacert
文件来解决此问题。更准确地说,我已将
cacert
中的
Eclipse Adoptium\jdk-17.0.1.12-hotspot
替换为
Eclipse Adoptium\jre-8.0.312.7-hotspot
来修复它。

令我惊讶的是,替换新的 cacaert 文件后,我不必使用 keytool 手动加载证书。为什么旧的 cacert 文件会造成麻烦仍然是个谜。

注意:在替换新的 cacert 文件之前,请备份原始 cacert 文件。

如果仍未解决,请尝试此解决方案


0
投票

将证书导入 cacert 文件后,我仍然收到相同的错误,但仅在 Spring Tool Suite 中,应用程序从 IBM z/OS Explorer 运行良好,它也是基于 Eclipse 构建的。
我的解决方案是将证书添加到我的信任存储 jks 文件中。

© www.soinside.com 2019 - 2024. All rights reserved.