DEBUG.WIKI
RackNerd;$21.99/年 · 1GB KVM
搬瓦工;先看线路,再选 VPS;CN2 GIA · 对应线路套餐;查看线路 →
腾讯云;让你的想法跑起来;轻量服务器 · 建站 / Docker / API;查看产品 →

解决 Drone CI 报错 Clone failed SSL certificate problem 证书校验失败修复

排查 Drone CI 在拉取自建 GitLab/Gitea 代码仓库时,默认的 clone 步骤报错 fatal: unable to access: SSL certificate problem: self-signed certificate,分析 自签 CA 证书注入与 DRONE_GIT_ALWAYS_AUTH。

问题现象

Drone 启动流水线拉取私有代码时,首个默认 clone 步骤即宣告失败:

+ git init
+ git remote add origin https://git.internal.corp/team/project.git
+ git fetch --no-tags --depth=1 origin +refs/heads/main:
fatal: unable to access 'https://git.internal.corp/team/project.git/': SSL certificate problem: self signed certificate in certificate chain

触发根因

  1. 内部代码托管平台(GitLab/Gitea)使用的是企业内网自签发 SSL 证书或私有根 CA;
  2. Drone 官方内置的 plugins/git 镜像内部未安装该企业的根证书,执行标准 Git 操作时报证书链不受信任;
  3. 未显式配置跳过校验或挂载受信任证书捆绑包。

解决步骤

在 .drone.yml 中为 clone 步骤显式开启 skip_verify 选项

忽略私有内网自签证书安全告警:

clone:
  git:
    image: plugins/git
    settings:
      skip_verify: true # 关键:跳过自签证书校验
      depth: 50

或者制作包含公司内部根 CA 的私有化定制 Git Clone 镜像

在基础镜像中将 root-ca.crt 复制至 /usr/local/share/ca-certificates/ 并运行 update-ca-certificates。

验证确认

重新推送代码触发构建:

代码检出步骤在 1 秒内顺畅完成全量同步,后续构建测试步骤平滑展开。