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

由于接口是HTTPS,本地没有证书,导致报

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

导出证书

Chrome浏览器导出HTTPS证书

创建一个Java信任库

创建一个Java信任库(Truststore),并将目标网站的SSL证书导入其中。使用java自带的keytool命令行工具来完成此操作。在cmd中使用命令:

keytool -import -keystore <信任库文件路径> -storepass <密码> -alias alias_for_certificate -file <证书文件路径>

该命令由4个部分组成:

keytool -import 用于导入的命令

-keystore <信任库文件路径> 希望生成的信任库文件,例如路径可以写:C:\Users\abc\Desktop\truststore.jks

-storepass <密码> 设置一个信任库密码

-alias alias_for_certificate -file <证书文件路径> 指定要导入的证书文件,例如可以写:C:\Users\abc\Desktop\cert.pem

如:

keytool -import -keystore '/Users/jimmy/Java/certificate/medextech.jks' -storepass '123456' -alias alias_for_certificate -file '/Users/jimmy/Thoth/ThothHis/SourceCode/thoth-his-fuwai/doc/medextech.cer'

SpringBoot项目中如何指定信任库

SpringApplication.run()增加两行代码。示例:

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
        // 代码放到这里 可以使用相对路径
        System.setProperty("javax.net.ssl.trustStore", "/Users/jimmy/Java/certificate/medextech.jks"); //信任库文件路径
        System.setProperty("javax.net.ssl.trustStorePassword", "123456");    //密码
    }
}


目录
相关文章
|
安全 Java API
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
网上有很多解决的帖子,我这里只是记录一下方便自己查阅 主要原因是java本身需要证书 1、按导入安全证书的方法解决
1520 0
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
|
网络安全
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://xxxx.svc.cluster.local:8080/xxxx": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "xxxx.svc.cluster.local:8080/xxxx ": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
4644 0
|
Java Maven Android开发
Maven神坑之PKIX path building failed终极解决办法
Maven神坑之PKIX path building failed终极解决办法
2247 2
Maven神坑之PKIX path building failed终极解决办法
|
Java 网络安全
Java 信任所有SSL证书(解决PKIX path building failed问题)
Java 信任所有SSL证书(解决PKIX path building failed问题)
26970 3
|
算法 Java 测试技术
java 访问ingress https报错javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version
java 访问ingress https报错javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version
1716 1
|
Web App开发
Chrome浏览器导出HTTPS证书
Chrome浏览器导出HTTPS证书
582 0
Chrome浏览器导出HTTPS证书
|
数据采集 Java Linux
Java异常之【sun.security.validator.ValidatorException: PKIX path building failed: sun.security...】
Java异常之【sun.security.validator.ValidatorException: PKIX path building failed: sun.security...】
501 0
Java异常之【sun.security.validator.ValidatorException: PKIX path building failed: sun.security...】
|
安全 Java Apache
异常:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/catoop/article/details/80819638 问题 java使...
24834 0
|
安全 Java 网络安全
如何在Java中处理SSLHandshakeException异常?
如何在Java中处理SSLHandshakeException异常?
2033 1
|
Android开发
解决Android、Flutter编译时Gradle报错:javax.net.ssl.SSLException: Connection reset
解决Android、Flutter编译时Gradle报错:javax.net.ssl.SSLException: Connection reset
1994 0