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");    //密码
    }
}


目录
相关文章
|
7月前
|
安全 Java API
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
网上有很多解决的帖子,我这里只是记录一下方便自己查阅 主要原因是java本身需要证书 1、按导入安全证书的方法解决
842 0
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
“Could not find suitable distribution for Requirement.parse(‘XXXX‘)”的问题
“Could not find suitable distribution for Requirement.parse(‘XXXX‘)”的问题
383 0
|
6月前
|
Python
【已解决】WARNING: Ignoring invalid distribution xxx
【已解决】WARNING: Ignoring invalid distribution xxx
|
7月前
|
缓存 数据安全/隐私保护 Windows
ECDSA host key for ... has changed and you have requested strict checking.Host key verification fail
ECDSA host key for ... has changed and you have requested strict checking.Host key verification fail
|
7月前
|
Kubernetes 容器
k8s-unable to connect to the server:x509:certificates signed by unknown authority......
k8s-unable to connect to the server:x509:certificates signed by unknown authority......
353 0
|
安全 Java 应用服务中间件
分析解决 PKIX path building failed 的问题
分析解决 PKIX path building failed 的问题
559 0
|
开发工具
WARNING: library configuration mismatch
WARNING: library configuration mismatch
329 0
|
Linux
ERROR: 2 matches found based on name: network product-server_default is ambiguous
ERROR: 2 matches found based on name: network product-server_default is ambiguous
168 0
|
网络协议 关系型数据库 Linux
onfigure: error: no acceptable C compiler found in $PATH See `config.log' for more details 问题解决
onfigure: error: no acceptable C compiler found in $PATH See `config.log' for more details 问题解决
190 0
|
安全 Java Apache
异常:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/catoop/article/details/80819638 问题 java使...
23423 0