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


目录
相关文章
|
6月前
|
安全 Java API
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
网上有很多解决的帖子,我这里只是记录一下方便自己查阅 主要原因是java本身需要证书 1、按导入安全证书的方法解决
793 0
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
|
开发者
上传苹果版本时错误解决办法:No suitable application records were found. Verify your bundle identifier
上传苹果版本时错误解决办法:No suitable application records were found. Verify your bundle identifier
112 2
|
安全 Java 应用服务中间件
分析解决 PKIX path building failed 的问题
分析解决 PKIX path building failed 的问题
488 0
|
开发工具
WARNING: library configuration mismatch
WARNING: library configuration mismatch
303 0
|
Kubernetes 安全 容器
Kubernetes CKS【18】---Supply Chain Security - Static Analysis(OPA)
Kubernetes CKS【18】---Supply Chain Security - Static Analysis(OPA)
Kubernetes CKS【18】---Supply Chain Security - Static Analysis(OPA)
|
网络协议 关系型数据库 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 问题解决
182 0
|
数据安全/隐私保护
remote: Support for password authentication was removed on August 13, 2021
remote: Support for password authentication was removed on August 13, 2021
192 0
|
安全 Java Apache
异常:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/catoop/article/details/80819638 问题 java使...
22986 0
|
并行计算 PyTorch 算法框架/工具
CUDA unknown error - this may be due to an incorrectly set up environment 问题解决
CUDA unknown error - this may be due to an incorrectly set up environment 问题解决
CUDA unknown error - this may be due to an incorrectly set up environment 问题解决
|
安全 Java 网络安全
PKIX path building failed
生产环境业务流程走不通,查了es后以为请求其他服务器资源有错,错误如下: [http-nio-9097-exec-1] sun.security.validator.ValidatorException: PKIX path building fai led: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target java
979 0