Maven編譯打包時報“PKIX path building failed”異常

提示:文章寫完后,目錄可以自動生成,如何生成可參考右邊的幫助文檔

文章目錄

  • 方法1
    • 1.報錯信息
    • 2.InstallCert.java
    • 3.生成證書文件 jssecacerts
    • 4.復制 jssecacerts 文件
    • 5. 然后重啟Jenkins 或者maven即可
  • 方法2
    • 1.下載證書
    • 2. 導入證書
      • 執行keytool指令
      • 刪除 別名命令


方法1

1.報錯信息

在這里插入圖片描述

com.google.guava:guava:pom:unknown failed to transfer from https://nexus.app.h5no1.com/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of rpgz has elapsed or updates are forced. Original error: Could not transfer artifact com.google.guava:guava:pom:unknown from/to rpgz (https://nexus.app.h5no1.com/repository/maven-public/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targetTry to run Maven import with -U flag (force update snapshots)

2.InstallCert.java

/** Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:**   - Redistributions of source code must retain the above copyright*     notice, this list of conditions and the following disclaimer.**   - Redistributions in binary form must reproduce the above copyright*     notice, this list of conditions and the following disclaimer in the*     documentation and/or other materials provided with the distribution.**   - Neither the name of Sun Microsystems nor the names of its*     contributors may be used to endorse or promote products derived*     from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/import java.io.*;
import java.net.URL;import java.security.*;
import java.security.cert.*;import javax.net.ssl.*;public class InstallCert {public static void main(String[] args) throws Exception {String host;int port;char[] passphrase;if ((args.length == 1) || (args.length == 2)) {String[] c = args[0].split(":");host = c[0];port = (c.length == 1) ? 443 : Integer.parseInt(c[1]);String p = (args.length == 1) ? "changeit" : args[1];passphrase = p.toCharArray();} else {System.out.println("Usage: java InstallCert <host>[:port] [passphrase]");return;}File file = new File("jssecacerts");if (file.isFile() == false) {char SEP = File.separatorChar;File dir = new File(System.getProperty("java.home") + SEP+ "lib" + SEP + "security");file = new File(dir, "jssecacerts");if (file.isFile() == false) {file = new File(dir, "cacerts");}}System.out.println("Loading KeyStore " + file + "...");InputStream in = new FileInputStream(file);KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());ks.load(in, passphrase);in.close();SSLContext context = SSLContext.getInstance("TLS");TrustManagerFactory tmf =TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());tmf.init(ks);X509TrustManager defaultTrustManager = (X509TrustManager)tmf.getTrustManagers()[0];SavingTrustManager tm = new SavingTrustManager(defaultTrustManager);context.init(null, new TrustManager[] {tm}, null);SSLSocketFactory factory = context.getSocketFactory();System.out.println("Opening connection to " + host + ":" + port + "...");SSLSocket socket = (SSLSocket)factory.createSocket(host, port);socket.setSoTimeout(10000);try {System.out.println("Starting SSL handshake...");socket.startHandshake();socket.close();System.out.println();System.out.println("No errors, certificate is already trusted");} catch (SSLException e) {System.out.println();e.printStackTrace(System.out);}X509Certificate[] chain = tm.chain;if (chain == null) {System.out.println("Could not obtain server certificate chain");return;}BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));System.out.println();System.out.println("Server sent " + chain.length + " certificate(s):");System.out.println();MessageDigest sha1 = MessageDigest.getInstance("SHA1");MessageDigest md5 = MessageDigest.getInstance("MD5");for (int i = 0; i < chain.length; i++) {X509Certificate cert = chain[i];System.out.println(" " + (i + 1) + " Subject " + cert.getSubjectDN());System.out.println("   Issuer  " + cert.getIssuerDN());sha1.update(cert.getEncoded());System.out.println("   sha1    " + toHexString(sha1.digest()));md5.update(cert.getEncoded());System.out.println("   md5     " + toHexString(md5.digest()));System.out.println();}System.out.println("Enter certificate to add to trusted keystore or 'q' to quit: [1]");String line = reader.readLine().trim();int k;try {k = (line.length() == 0) ? 0 : Integer.parseInt(line) - 1;} catch (NumberFormatException e) {System.out.println("KeyStore not changed");return;}X509Certificate cert = chain[k];String alias = host + "-" + (k + 1);ks.setCertificateEntry(alias, cert);OutputStream out = new FileOutputStream("jssecacerts");ks.store(out, passphrase);out.close();System.out.println();System.out.println(cert);System.out.println();System.out.println("Added certificate to keystore 'jssecacerts' using alias '"+ alias + "'");}private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray();private static String toHexString(byte[] bytes) {StringBuilder sb = new StringBuilder(bytes.length * 3);for (int b : bytes) {b &= 0xff;sb.append(HEXDIGITS[b >> 4]);sb.append(HEXDIGITS[b & 15]);sb.append(' ');}return sb.toString();}private static class SavingTrustManager implements X509TrustManager {private final X509TrustManager tm;private X509Certificate[] chain;SavingTrustManager(X509TrustManager tm) {this.tm = tm;}public X509Certificate[] getAcceptedIssuers() {throw new UnsupportedOperationException();}public void checkClientTrusted(X509Certificate[] chain, String authType)throws CertificateException {throw new UnsupportedOperationException();}public void checkServerTrusted(X509Certificate[] chain, String authType)throws CertificateException {this.chain = chain;tm.checkServerTrusted(chain, authType);}}}

3.生成證書文件 jssecacerts

在該java文件所在的目錄下,打開cmd界面

 `javac InstallCert.java`

在這里插入圖片描述
然后執行

  • 例如:博主這里要訪問的是清華大學開源鏡像網站(https://mirrors.tuna.tsinghua.edu.cn/) 執行
    java InstallCert.java mirrors.tuna.tsinghua.edu.cn
 `java InstallCert.java nexus.app.h5no1.com`

在這里插入圖片描述

4.復制 jssecacerts 文件

將 jssecacerts 文件復制到 $JAVA_HOME/jre/lib/security 目錄下
$JAVA_HOME 為大家JDK安裝的目錄
在這里插入圖片描述

5. 然后重啟Jenkins 或者maven即可

方法2

1.下載證書

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

2. 導入證書

執行keytool指令

-file后面的文件名修改為自己的。同時修改jdk安裝目錄下的cacerts文件的位置,注意需要絕對路徑才行。

keytool -import -alias subconverter -file "C:\Users\EDY\Desktop\fsdownload\nexus.app.h5no1.crt" -keystore "D:\JDK\jdk1.8.0_121\JDK\jre\lib\security\cacerts" -storepass changeit
keytool -import -alias subconverter -file "C:\Users\EDY\Desktop\fsdownload\ISRG Root X1.crt" -keystore "D:\JDK\jdk1.8.0_121\JDK\jre\lib\security\cacerts" -storepass changeit

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

刪除 別名命令

需要注意的是證書是有截止日期的,過期了需要重新導入。
證書過期了如何再次導入

需要先刪除過期的證書,再執行上面的導入指令即可。

keytool -delete -alias subconverter -keystore "D:\JDK\jdk1.8.0_121\JDK\JRE\lib\security\cacerts" -storepass changeit

在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/38022.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/38022.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/38022.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

7.優化算法之分治-快排歸并

0.分治 分而治之 1.顏色分類 75. 顏色分類 - 力扣&#xff08;LeetCode&#xff09; 給定一個包含紅色、白色和藍色、共 n 個元素的數組 nums &#xff0c;原地對它們進行排序&#xff0c;使得相同顏色的元素相鄰&#xff0c;并按照紅色、白色、藍色順序排列。 我們使用整數…

Elasticsearch (1):ES基本概念和原理簡單介紹

Elasticsearch&#xff08;簡稱 ES&#xff09;是一款基于 Apache Lucene 的分布式搜索和分析引擎。隨著業務的發展&#xff0c;系統中的數據量不斷增長&#xff0c;傳統的關系型數據庫在處理大量模糊查詢時效率低下。因此&#xff0c;ES 作為一種高效、靈活和可擴展的全文檢索…

PHP爬蟲類的使用技巧與注意事項

php爬蟲類的使用技巧與注意事項 隨著互聯網的迅猛發展&#xff0c;大量的數據被不斷地生成和更新。為了方便獲取和處理這些數據&#xff0c;爬蟲技術應運而生。PHP作為一種廣泛應用的編程語言&#xff0c;也有許多成熟且強大的爬蟲類庫可供使用。在本文中&#xff0c;我們將介…

Qt Creator 的設置文件保存位置

在使用 Qt Creator 進行開發時,備份或遷移設置(例如文本編輯器偏好、語法高亮等)是常見需求。了解這些設置文件在不同操作系統中的保存位置,可以簡化這個過程。本文將為您詳細介紹 Qt Creator 保存設置文件的位置。 默認文件位置 Qt Creator 會創建多個文件和目錄來存儲其…

springboot系列八: springboot靜態資源訪問,Rest風格請求處理, 接收參數相關注解

文章目錄 WEB開發-靜態資源訪問官方文檔基本介紹快速入門注意事項和細節 Rest風格請求處理基本介紹應用實例注意事項和細節思考題 接收參數相關注解基本介紹應用實例PathVariableRequestHeaderRequestParamCookieValueRequestBodyRequestAttributeSessionAttribute ?? 上一篇…

微服務-網關Gateway

個人對于網關路由的理解&#xff1a; 網關就相當于是一個項目里面的保安&#xff0c;主要作用就是做一個限制項。&#xff08;zuul和gateway兩個不同的網關&#xff09; 在路由中進行配置過濾器 過濾器工廠&#xff1a;對請求或響應進行加工 其中filters&#xff1a;過濾器配置…

探索QCS6490目標檢測AI應用開發(三):模型推理

作為《探索QCS6490目標檢測AI應用開發》文章&#xff0c;緊接上一期&#xff0c;我們介紹如何在應用程序中介紹如何使用解碼后的視頻幀結合Yolov8n模型推理。 高通 Qualcomm AI Engine Direct 是一套能夠針對高通AI應用加速的軟件SDK&#xff0c;更多的內容可以訪問&#xff1a…

摸魚大數據——Spark基礎——Spark環境安裝——PySpark搭建

三、PySpark環境安裝 PySpark: 是Python的庫, 由Spark官方提供. 專供Python語言使用. 類似Pandas一樣,是一個庫 Spark: 是一個獨立的框架, 包含PySpark的全部功能, 除此之外, Spark框架還包含了對R語言\ Java語言\ Scala語言的支持. 功能更全. 可以認為是通用Spark。 功能 P…

Golang | Leetcode Golang題解之第199題二叉樹的右視圖

題目&#xff1a; 題解&#xff1a; /** 102. 二叉樹的遞歸遍歷*/ func levelOrder(root *TreeNode) [][]int {arr : [][]int{}depth : 0var order func(root *TreeNode, depth int)order func(root *TreeNode, depth int) {if root nil {return}if len(arr) depth {arr a…

線性代數--行列式1

本篇來自對線性代數第一篇的行列式的一個總結。 主要是行列式中有些關鍵點和注意事項&#xff0c;便于之后的考研復習使用。 首先&#xff0c;對于普通的二階和三階行列式&#xff0c;我們可以直接對其進行拆開&#xff0c;展開。 而對于n階行列式 其行列式的值等于它的任意…

每個架構師都應該讀的八本經典書籍

格雷戈爾霍普在本文討論了8本被視為軟件架構師必讀的經典書籍。 以下是所提及的關鍵書籍的摘要&#xff1a; 1、維特魯威&#xff08;公元前 20 年&#xff09;的《建筑學》&#xff1a; 雖然與軟件架構沒有直接關系&#xff0c;但這部古代文獻被提及&#xff0c;具有歷史背景…

C++特殊類設計單例模式...

文章目錄 請設計一個類&#xff0c;不能被拷貝請設計一個類&#xff0c;只能在堆上創建對象請設計一個類&#xff0c;只能在棧上創建對象請設計一個類&#xff0c;不能被繼承請設計一個類&#xff0c;只能創建一個對象(單例模式)單例模式&#xff1a;餓漢模式&#xff1a;懶漢模…

代發考生戰報:6月25號 南寧 HCIP-Transmission傳輸 H31-341考試884分通過

代發考生戰報&#xff1a;6月25號 南寧 HCIP-Transmission傳輸 H31-341考試884分通過 &#xff0c;今天我和同事兩個人去考的&#xff0c;我考試遇到1個新題&#xff0c;他遇到兩個新題&#xff0c;客服提供的題庫很穩定&#xff0c;全覆蓋了&#xff0c;輕松通過&#xff0c;考…

【語言模型】Xinference的部署過程

一、引言 Xinference&#xff0c;也稱為Xorbits Inference&#xff0c;是一個性能強大且功能全面的分布式推理框架&#xff0c;專為各種模型的推理而設計。無論是研究者、開發者還是數據科學家&#xff0c;都可以通過Xinference輕松部署自己的模型或內置的前沿開源模型。Xinfe…

pikachu靶場 利用Rce上傳一句話木馬案例(工具:中國蟻劍)

目錄 一、準備靶場&#xff0c;進入RCE 二、測試寫入文件 三、使用中國蟻劍 一、準備靶場&#xff0c;進入RCE 我這里用的是pikachu 打開pikachu靶場&#xff0c;選擇 RCE > exec "ping" 測試是否存在 Rce 漏洞 因為我們猜測在這個 ping 功能是直接調用系統…

性能評測系列:云架構擴展演進橫向對比

原始測評報告 性能評測系列&#xff08;PT-010&#xff09;&#xff1a;Spring Boot RDS for MySQL&#xff0c;高并發insert 性能評測系列&#xff08;PT-012&#xff09;&#xff1a;Spring Boot(K8s多實例) RDS for MySQL&#xff0c;高并發insert 性能評測系列&#xff…

一元線性回歸-R語言

# # 安裝包 # install.packages(ggplot2) # library(ggplot2) Sys.setlocale(category LC_ALL, locale English_United States.1252) # Sys.setlocale("LC_ALL","Chinese") x <- c(18, 20, 22, 24, 26, 28, 30) y <- c(26.86, 28.35, 28.87,28.75,…

Linux——vim的配置文件+異常處理

vim的配置文件&#xff1a; [rootserver ~]# vim /etc/vimrc # 輸入以下內容 set nu # 永久設置行號 shell [rootserver ~]# vim /etc/vimrc 或者 vim ~/.vimrc set hlsearch "高亮度反白 set backspace2 "可隨時用退格鍵刪除 set autoindent…

期貨的杠桿怎么計算?

什么是杠桿系數 杠桿系數是指期貨合約價值與保證金之間的比例。它表示投資者只需投入少量資金&#xff0c;就可以控制價值更高的期貨合約。杠桿系數越高&#xff0c;投資者的資金放大倍數就越大&#xff0c;但風險也越大。 什么是期貨保證金呢&#xff1f; 期貨保證金&…

《HelloGitHub》第 99 期

興趣是最好的老師&#xff0c;HelloGitHub 讓你對編程感興趣&#xff01; 簡介 HelloGitHub 分享 GitHub 上有趣、入門級的開源項目。 github.com/521xueweihan/HelloGitHub 這里有實戰項目、入門教程、黑科技、開源書籍、大廠開源項目等&#xff0c;涵蓋多種編程語言 Python、…