搜索
toc
Latest Post

记一次 Redis OOM

解决 Clash 开启后 Google Play 无法更新下载软件

树莓派4b从 SD 卡迁移至 SSD

网站记录

230513-顾村公园

SSL certificate problem: unable to get local issuer certificate 解决方法

❤ Jun Xie

最近在一台 Ubuntu 上使用 curl 时报错,比如下面:

curl https://api.shellj.com/ip/1.1.1.1
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

更新:先检查是不是 nginx 证书配置错误了, 证书链不完整,可以在 https://myssl.com/ 检查一下,如果不完整,下载下来配置上就好了。

根据提供的网页信息,可以有几种方法解决这个问题。

不验证证书

最简单,可以使用参数 -k/–insecure 禁用。

curl https://api.shellj.com/ip/1.1.1.1 -k
curl https://api.shellj.com/ip/1.1.1.1 --insecure

指定证书地址

需要把证书链上的证书下载下来(我这里直接用 Microsoft Edge 下载),合并成一个,根证书最上面,不需要你访问网站的证书,比如我这里只需要 GlobalSign Root CA - R1AlphaSSL CA -SHA256 - G2 的证书。

cert1

cert2

cert3


curl https://api.shellj.com/ip/1.1.1.1 --cacert /tmp/chain.cer

将证书安装到系统里面

我这里使用 Ubuntu 安装,将上面下载下来的证书放到 /usr/local/share/ca-certificates/ 下,并重命名为 .crt 结尾,我的系统里面已经有 GlobalSign 的证书,只把 AlphaSSL 证书放进去就好了,然后执行 sudo update-ca-certificates 就可以了。

sudo cp /tmp/alpha.cer /usr/local/share/ca-certificates/alpha.crt
sudo update-ca-certificates

当然还有其他方法,这里只是常用的一些,可以去官方参考页面查看更多。

参考:https://curl.haxx.se/docs/sslcerts.html
Relate Post

ffmpeg视频截取,ffmpeg音频截取

Docker Container Cannot Connect Internet

Rust 开发环境配置

Kafka 基础应用

WordPress 安装后必要的插件