DEBUG.WIKI
IPPeak:从目标地区访问网页,住宅代理、SEO 监测、广告验证
阿里云;从建站到云上业务;云服务器 · 数据库 · 对象存储;查看产品 →
搬瓦工;先看线路,再选 VPS;CN2 GIA · 对应线路套餐;查看线路 →

解决 Linux curl 报错 curl 60 peer certificate cannot be authenticated 证书信任修复

排查 curl 请求提示 curl: (60) SSL certificate problem: unable to get local issuer certificate,安装 ca-certificates 与导入企业私有自签证书。

问题现象

在 Linux 服务器上执行 curl 或调用第三方 API 时报错拒绝:

curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not 
establish a secure connection to it.

触发根因

  1. 宿主机的系统 CA 证书信任库严重过期或未安装:系统中缺少国际根证书颁发机构(如 Let's Encrypt / DigiCert / Sectigo)的最新信任锚点;
  2. 目标服务器配置了内部自签名的私有 CA 证书,而客户端本地的 OpenSSL 证书链中并不信任该私有 CA;
  3. 服务端未正确配置完整的证书中间链(Intermediate Certificate Missing)。

解决步骤

1. 更新系统公共 CA 证书包

在终端安装并刷新系统全局受信任证书:

# Debian / Ubuntu
sudo apt-get update && sudo apt-get install --reinstall ca-certificates -y
sudo update-ca-certificates

# CentOS / RHEL
sudo yum reinstall ca-certificates -y
sudo update-ca-trust

2. 将企业私有根证书导入系统永久信任库

若为企业私服(如内网 Harbor/GitLab):

# 将私有 ca.crt 复制至锚点目录
sudo cp my_company_ca.crt /usr/local/share/ca-certificates/
# 刷新系统信任库
sudo update-ca-certificates

3. 在单次测试中显式指定证书文件(避免生产中滥用 -k)

curl --cacert /path/to/my_company_ca.crt https://internal.example.com/

验证确认

再次执行标准 curl 命令:

curl -I https://internal.example.com/

控制台成功打印 HTTP/2 200,证书签名验证绿灯通过。