后端请求https协议接口地址报错

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

at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)

at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1964)

at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:328)

at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:322)

原因:请求没有携带https证书,需要手动将证书导入到服务器上

操作步骤:

1.浏览器里访问接口地址,然后导出证书

2.将证书传到服务器上,然后通过命令导入到 jdk里(注意要程序使用的jdk,不同的jdk的密钥路径不一样找到目录 /jre/lib/security/cacerts),youserver 这个你自己定义名字,然后用下面的命令

keytool -importcert -alias youserver -file base.crt -keystore /home/jdk1.8.0_172/jre/lib/security/cacerts

3.执行后会先让输入密码

直接复制就行: changeit 输入后回车

4.然后在输入一个 y,成功之后重启服务就可以了

相关推荐
要吃这碗饭11 小时前
深入理解 TCP 协议:从三次握手到可靠传输
网络·网络协议·tcp/ip
Zelman15 小时前
HTTPS 协议
网络协议·https
JVM高并发17 小时前
使用 Cloudflare Tunnel(本地管理隧道)搭配 DigitalPlat 免费域名实现内网穿透
网络协议·全栈
吴声子夜歌17 小时前
Nginx应用与运维——Nginx HTTP模块详解(动态赋值功能模块)
运维·nginx·http
Zelman18 小时前
网络协议性能调优手册
网络协议·性能优化
Zelman18 小时前
TCP-IP 协议栈设计哲学
网络协议
姜鱼问生18 小时前
HTTPS 部署实战:未备案域名 + 非标端口的完整方案
linux·https
阿钱真强道18 小时前
28 嵌入式操作系统 | 网关加 TCP 命令通道:粘包/半包怎么切
网络·网络协议·tcp/ip·粘包
hasty19 小时前
一次 WebSocket 握手为何能终止进程?Undici CVE-2026-19534 的异常边界
网络·websocket·网络协议
hasty20 小时前
前缀相同不代表同一网络:ip-address 跨地址族比较缺陷
网络·网络协议·tcp/ip