在java中使用https访问数据时报异常:

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

需要使用keytool工具,将对应域名的证书导入到jdk的cacerts中,这个证书可以是*.crt,*.cer等证书

cacerts包含了很多CA证书,位置在Java的安装目录: Java\jdk1.8.0_181\jre\lib\security\cacerts

执行如下命令,可将证书导入到cacerts中,使其成为可信证书:

cd D:\IDE\Java\jdk1.8.0_181\jre\lib\security
keytool -importcert -alias httpfs -keystore cacerts -file D:\IDE\Java\jdk1.8.0_181\jre\lib\security\ssl.cer

需要输入cacerts证书库密码:changeit

如果没有证书,可以使用Chrome浏览器访问https域名,下载对应的证书,详情请参照:https://blog.csdn.net/qq_31222053/article/details/94174506

java程序中访问https时,报 PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target的更多相关文章

  1. 解决 java 使用ssl过程中出现"PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"

    今天,封装HttpClient使用ssl时报一下错误: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorExc ...

  2. Flutter配置环境报错“PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target”

    背景:最近看了很多Flutter漂亮的项目,想要尝试一下.所有环境都搭建好之后,按照文档一步一步配置(抄袭),但始终报如下图错误. PKIX path building failed: sun.sec ...

  3. mvn 编译报错mavn sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targ

    mavn 编译报错: mavn sun.security.validator.ValidatorException: PKIX path building failed: sun.security.p ...

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

    注:网上搜来的快照,暂未验证 在java代码中请求https链接的时候,可能会报下面这个错误javax.net.ssl.SSLHandshakeException: sun.security.vali ...

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

    还是记录使用 maven 时遇到的问题. 一.maven报错 maven package 进行打包时出现了以下报错: Non-resolvable parent POM for com.wpbxin: ...

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

    今天在调用第三方HTTPS接口的时候,一直显示这个报错,然后百度很久,有2种解决方法,一个是说自己手动去导入,第二种用代码忽略证书验证.我用二种方式, 复制即用, public void test2( ...

  7. ES访问遇到sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

    cmd命令cd到jre/bin目录下 输入命令keytool -import -alias 别名 -keystore cacerts -file ‪C://certs//elasticsearch// ...

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

    maven编译的时候遇到的奇葩问题,  非常奇葩, 所有其他同事都没有遇到 , 仅仅是我遇到了 不清楚是因为用了最新的JDK的缘故(1.8 update91)还是其他什么原因. 总之是证书的问题. 当 ...

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

    httpclient-4.5.jar 定时发送http包,忽然有一天报错,http证书变更引起的. 之前的代码 try { CloseableHttpClient httpClient = build ...

随机推荐

  1. Git与Repo 的使用

    一.Linux常用命令 pwd           用于显示工作目录,执行pwd指令可立刻得知您目前所在的工作目录的绝对路径名称. chmod      用来变更文件或目录的权限. >      ...

  2. DMA数据传输

    从字面意思上看,DMA即为“直接内存读取”的意思,换句话说DMA就是用来传输数据的,它也属于一个外设.只是在传输数据时,无需占用CPU. 高速IO设备可以在处理器安排下直接与主存储器成批交换数据,称为 ...

  3. Nginx-rtmp之 ngx_rtmp_send.c 文件分析

    1. 简述 1.1 RTMP 消息类型 /* RTMP message types */ #define NGX_RTMP_MSG_CHUNK_SIZE 1 #define NGX_RTMP_MSG_ ...

  4. tp5中很牛皮的一句sql语句,三个条件(两个不确定条件,一个硬性条件)

    $result = Db::table('xxxxxx')   // 表名 ->alias('g') ->join('xxxxx_2 u','g.user_id = u.id') -> ...

  5. JSP——JavaServer Page中的隐式对象(implicit object)、指令(directive)、脚本元素(scripting element)、动作(action)、EL表达式

    目录 1.JSP概述 2.注释(comment) 2.1.JSP注释 2.2.HTML注释 3.隐式对象(implicit object) 3.1.隐式对象清单 3.2.request对象 3.3.o ...

  6. CentOS7——卡在在启动界面

    系统在启动时,卡在启动界面比如: 解决方法一 这个时候其实系统已经启动了,如果这台机器之前正确配置好了网络连接的话,此时我们可以使用另外一台机器通过SSH来登录这台机器进行修改. 这个时候将系统出问题 ...

  7. LC 245. Shortest Word Distance III 【lock, medium】

    Given a list of words and two words word1 and word2, return the shortest distance between these two ...

  8. 使用ViewFlipper实现广告图片的自动轮播的效果

    轮播资源图片的实现 package com.loaderman.viewflipperdemo; import android.os.Bundle; import android.support.v7 ...

  9. LoadRunner书籍推荐

    精通软件性能测试与LoadRunner实战 性能技巧查询 软件性能测试过程详解与案例剖析----读 性能测试理论 性能测试进阶指南-------loadrunner 9.1实战 这是一本比loadru ...

  10. 初探ASP.NET Web API (转)

    http://www.cnblogs.com/mejoy/p/6402821.html 什么是ASP.NET Web API? 官方的解释是 ASP.NET Web API is a framewor ...