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


目录
相关文章
|
8月前
|
安全 Java API
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
网上有很多解决的帖子,我这里只是记录一下方便自己查阅 主要原因是java本身需要证书 1、按导入安全证书的方法解决
905 0
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
|
8月前
|
缓存 数据安全/隐私保护 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
|
8月前
|
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......
418 0
|
安全 Java 应用服务中间件
分析解决 PKIX path building failed 的问题
分析解决 PKIX path building failed 的问题
664 0
|
开发工具
WARNING: library configuration mismatch
WARNING: library configuration mismatch
343 0
|
安全 Java Apache
异常:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/catoop/article/details/80819638 问题 java使...
23748 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 问题解决
201 0
|
安全 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
1029 0
|
Java 安全 网络安全
请求https错误: unable to find valid certification path to requested target
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/catoop/article/details/51155224 错误及原因 当Java客户端请求实现https协议的服务时,出现异常:’unable to find valid certification path to requested target’ 是因为服务期端的证书没有被认证,需要做的是把服务端证书导入到Java keystore。
8467 0