方法一

在eclipse工程上使用maven->update project时报错:

PKIX path building failed: SunCertPathBuilderException: unable to find valid certification path to requested target

一般出现这种错误原因有以下几种

  1. maven库是https地址,本地JDK中没有这个网址的证书
  2. maven库是https地址,这个证书过期了或被更新了,但本地JDK中存的是旧证书

像我这个报错主要是因为使用的maven库是https地址:

<mirror>

    <id>......</id>

    <name>......</name>

    <url>https://XXXXX</url>

</mirror>

而这个url的证书在JDK的证书库不存在造成的

<JAVA_HOME>jre/lib/security/cacerts

因此,只需要将这个url的证书导出,再导入到cacerts中就可以了。

导入的方法可以使用命令,比如:

keytool -importcert -file jetty.crt -alias jetty -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit

如果本地是旧证书,则在执行上述命令前,先把旧证书删除

keytool -delete -alias jetty -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit

 执行完以上操作后,最好把PC重启一下。

方法二

在eclipse工具栏上选中“Run Configurations”,在“Maven Build”中选中需要运行的Maven项目,选中其中的“offline”选项。

其它方法可参考如下文档:

"PKIX path building failed" and "unable to find valid certification path to requested target"
https://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ

PKIX path building failed: SunCertPathBuilderException: unable to find valid certification path to requested target
https://magicmonster.com/kb/prg/java/ssl/pkix_path_building_failed/

Solve “unable to find valid certification path to requested target”
https://blog.packagecloud.io/solve-unable-to-find-valid-certification-path-to-requested-target/

【keytool】keytool查看jks证书详情
https://blog.csdn.net/michaelwoshi/article/details/107993556

Maven:sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
https://www.cnblogs.com/wpbxin/p/11746229.html

使用Maven时出现“jssecacerts PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilde”错
https://blog.csdn.net/carrie__yang/article/details/79612385

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐