maven-pom报错PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException

本文介绍了三种解决maven报错PKIX path building failed的方法:生成jssecacerts、下载.cer文件导入及更换maven镜像。尝试更换阿里云镜像仓库后,问题得到解决。
摘要由CSDN通过智能技术生成

问题描述:

Failure to transfer org.apache.maven:maven-archiver:pom:2.5 from
https://maven.aliyun.com/repository/public was cached in the local repository, resolution
will not be reattempted until the update interval of aliyunmaven has elapsed or updates are forced. 
Original error: Could not transfer artifact org.apache.maven:maven-archiver:pom:2.5 from/to
aliyunmaven (https://maven.aliyun.com/repository/public): PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid 
 certification path to requested target

maven用了阿里云镜像,之前一直没问题,今天突然显示要安全证书,网上找了方法:

方法一,生成jssecacerts(本人多次尝试,没有解决我的问题)

创建Java文件,InstallCert.java,代码:

 
import java.io.BufferedReader;  
import java.io.File;  
import java.io.FileInputStream;  
import java.io.FileOutputStream;  
import java.io.InputStream;  
import java.io.InputStreamReader;  
import java.io.OutputStream;  
import java.security.KeyStore;  
import java.security.MessageDigest;  
import java.security.cert.CertificateException;  
import java.security.cert.X509Certificate;  
  
import javax.net.ssl.SSLContext;  
import javax.net.ssl.SSLException;  
import javax.net.ssl.SSLSocket;  
import javax.net.ssl.SSLSocketFactory;  
import javax.net.ssl.TrustManager;  
import javax.net.ssl.TrustManagerFactory;  
import javax.net.ssl.X509TrustManager;  
  
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) ?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException是一个常见的SSL握手错误。它表示在构建证书路径时出现了问题,导致SSL握手失败。 解决这个问题的方法有几种。一种是手动导入证书到本地的信任库,这需要按照一些复杂的教程进行操作。另一种方法是信任SSL证书,这可以通过在项目中设置一些参数来实现。具体来说,在使用腾讯云接入短信SDK时,可以在Maven设置参数中加入"-Dmaven.wagon.http.ssl.insecure=true"和"-Dmaven.wagon.http.ssl.allowall=true"的参数。这样设置后,就会忽略SSL证书的认证,从而解决这个错误。需要注意的是,对于新的项目,每次都需要添加这个参数才能避免错误的发生。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [InstallCert.java工具及使用方法.zip](https://download.csdn.net/download/asdfdg/11443932)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [解决PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException](https://blog.csdn.net/qq_44900959/article/details/106417142)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值