gitlab-runner 的 git clone 失败并显示“SSL CA 证书问题(路径?访问权限?)”

时间:2021-01-13 11:02:31

标签: ssl gitlab gitlab-ci-runner

几个月来,我遇到了 gitlab-runner 的问题,它随机失败并显示以下日志:

Running with gitlab-runner 13.7.0 (943fc252)
  on <gitlab-runner-name> <gitlab-runner-id>
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on <hostname>...
Getting source from Git repository
00:00
Fetching changes...
Reinitialized existing Git repository in /var/gitlab-runner/builds/<gitlab-runner-id>/0/<gtlab-group>/<gitlab-project>/.git/
fatal: unable to access 'https://gitlab-ci-token:[MASKED]@<hostname>/<gtlab-group>/<gitlab-project>.git/': Problem with the SSL CA cert (path? access rights?)
ERROR: Job failed: exit status 1

这一行很关键:

fatal: unable to access 'https://gitlab-ci-token:[MASKED]@<hostname>/<gtlab-group>/<gitlab-project>.git/': Problem with the SSL CA cert (path? access rights?)

我尝试取消注册跑步者并注册一个新跑步者。一段时间后,它也因相同的错误而失败(第一次运行通常效果很好)。
此外,其他机器上的运行器工作正常,永远不会因上述错误消息而失败。

我认为该问题是由以下位置丢失的 CI_SERVER_TLS_CA_FILE 文件引起的:

/var/gitlab-runner/builds/<gitlab-runner-id>/0/<gtlab-group>/<gitlab-project>.tmp/CI_SERVER_TLS_CA_FILE

我尝试在错误的目录中执行 git pull 并且收到相同的消息。从另一个拥有它的目录复制这个丢失的文件后,我得到以下内容:

remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab-ci-token:<gitlab-runner-token>@gitlab.lab.sk.alcatel-lucent.com/<gtlab-group>/<gitlab-project>.git/'

据我所知,这些令牌是一次性使用的,并在作业完成后被丢弃。这让我相信丢失的文件是问题所在。

这个文件是从哪里复制的?为什么不见了?我该怎么做才能解决这个问题?
我一直在查看 GitLab 问题,但运气不佳。

1 个答案:

答案 0 :(得分:0)

听起来您的一个或多个运行者不信任您的 gitlab 主机上的证书。您必须追踪用于签署 TLS 证书的根证书和中间证书,并将其添加到运行者的主机中。

对于 CentOS 上的跑步者,我遵循此指南(对于 CentOS,更高版本的命令相同):https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html