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


目录
相关文章
|
4月前
|
安全 Java API
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
网上有很多解决的帖子,我这里只是记录一下方便自己查阅 主要原因是java本身需要证书 1、按导入安全证书的方法解决
663 0
Eclipse 打开marketplace 报PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
|
12月前
|
安全 Java 应用服务中间件
分析解决 PKIX path building failed 的问题
分析解决 PKIX path building failed 的问题
418 0
|
开发工具
WARNING: library configuration mismatch
WARNING: library configuration mismatch
274 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 问题解决
176 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
917 0
|
安全 Java Apache
异常:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/catoop/article/details/80819638 问题 java使...
22094 0
How to resolve warning message Access restriction -The type Resource is not accessible
How to resolve warning message Access restriction -The type Resource is not accessible
How to resolve warning message Access restriction -The type Resource is not accessible
|
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。
8300 0
|
SQL Windows
Unable to determine if the owner (Domain\UserName) of job JOB_NAME has server access
早上巡检的的时候,发现一数据库的作业报如下错误(作业名等敏感信息已经替换),该作业的OWNER为一个域账号: JOB RUN: 'JOB_NAME' was run on 2016-6-1 at 7:00:00 DURATION: 0 hours, 0 minutes, 1 seconds STATUS: Failed MESSAGES: The job failed.
1420 0