1. 程式人生 > 其它 >PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

問題截圖:無法找到請求目標的有效證書路徑

jar包更新失敗:.lastUpdated

報錯資訊

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Could not transfer artifact org.apache.maven.archetypes:maven

本人使用的maven版本:3.8.4

解決思路1:maven clean -> maven : update preject

解決思路2:重新配置maven

解決思路3:忽略證書 -> 在Eclipse的Maven設定裡將Global checksum policy從default設定成ignore就可以關閉這個校驗:

解決思路4:在執行maven命令時忽略證書檢查

在新建maven工程時,會自執行maven的各種命令

在此處設定忽略證書檢查

-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

  

解決思路5:手動匯入證書

  • 確保maven中setting檔案中的阿里源配置正確 (注意url中協議為https!)
  • 將阿里映象庫的證書加到信任證書庫裡面
  • 開啟上面阿里源的網址
  • https://maven.aliyun.com/nexus/content/groups/public或https://maven.aliyun.com/repository/central都是一樣的
  • 通過chrome瀏覽器下載證書到本地
  • 開啟上面阿里源的網址
  • 一路next,將檔案命名為ali_maven,字尾預設為.cer,儲存到D盤根目錄
  • 通過證書新增到java信任證書庫
cacerts包含了很多CA證書,位置在Java的安裝目錄:如: C:\Program Files\Java17\lib\security\carcerts

  

  • 以管理員身份開啟命令提示符(cmd)
  • 進入carcerts所在檔案目錄
  • 執行命令keytool -import -alias cacerts -keystore cacerts -file d:\ali_maven.cer
  • 預設金鑰庫口令:changeit
  • 是否信任此證書?[否]: Y
  • 顯示證書已新增到金鑰庫中即表示新增成功
  • 回到專案中重新clean,compile,解決

注:以前方案並未解決我的問題,我以為自己把電腦環境搞壞了,又重新裝系統又試了,出現如下問題

儲存庫的映象被封

Non-resolvable parent POM for com.beyondsoft.sabg.ImagingBiosen:server:0.0.1-SNAPSHOT: 
 org.springframework.boot:spring-boot-starter-parent:pom:2.4.4 failed to transfer from http://0.0.0.0/ 
 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted 
 until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: 
 Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.4.4 from/to maven-
 default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [maven-default-http-blocker (http://
 0.0.0.0/, default, releases)]

最終解決思路6:降低Maven 版本到3.8.1 以下

https://blog.csdn.net/hadues/article/details/119038072