【问题标题】:git not fully working with self-signed certgit 没有完全使用自签名证书
【发布时间】:2015-07-03 13:33:53
【问题描述】:

我使用自签名证书进行加密。
经过一些工作,https 对 git 有效,但 git@xxxxx 方式不起作用。这是输出:

Cloning into 'test'...
/usr/lib/ruby/1.9.1/net/http.rb:762:in `initialize': Connection refused - connect(2 (Errno::ECONNREFUSED)
    from /usr/lib/ruby/1.9.1/net/http.rb:762:in `open'
    from /usr/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
    from /usr/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
    from /usr/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
    from /usr/lib/ruby/1.9.1/net/http.rb:762:in `connect'
    from /usr/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
    from /usr/lib/ruby/1.9.1/net/http.rb:744:in `start'
    from /home/git/gitlab-shell/lib/gitlab_net.rb:56:in `get'
    from /home/git/gitlab-shell/lib/gitlab_net.rb:17:in `allowed?'
    from /home/git/gitlab-shell/lib/gitlab_shell.rb:51:in `validate_access'
    from /home/git/gitlab-shell/lib/gitlab_shell.rb:21:in `exec'
    from /home/git/gitlab-shell/bin/gitlab-shell:16:in `<main>'
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

在我开始自签名证书之前,ssh 和 http 都可以正常工作,所以现在 ssh+ssl 无法正常工作。 我正在使用 nginx,gitlab 5.3,按照 gitlab 网站上的安装说明进行操作。

我也做了检查。

~> sudo -u git -H /home/git/gitlab-shell/bin/check
Check GitLab API access: FAILED. code: 301

Check directories and files: 
    /home/git/repositories: OK
    /home/git/.ssh/authorized_keys: OK

我认为 301 可能是我的 nginx 配置中的这一部分:

server {
     listen         80;
     server_name    gitlab.MYDOMAIN.com;
     rewrite        ^ https://$server_name$request_uri? permanent;
}

不知道是不是有关系 谢谢。

【问题讨论】:

    标签: ssl gitlab


    【解决方案1】:

    您遇到的问题是,当您启用 ssl 时,您还将 http 重定向到 https。

    访问旧的http:// url 适用于大多数客户端,但 gitlab-shell(用作 gitlab 服务器上的登录过程的一部分)不会遵循 3xx 重定向而是返回错误,从而禁用基于 ssh 的访问。

    修复方法是编辑/home/git/gitlab-shell/config.yml 并将gitlab_url: 中的http:// 替换为https://

    如果您使用自签名证书,您可能还需要在http_settings: 下设置self_signed_cert: true

    【讨论】:

      【解决方案2】:

      对于 gitlab 6.0,这为我解决了错误:如果使用自签名证书,请确保在 gitlab-shell/config.yml 你的 gitlab_url 是 https://... 而不是 http://...你指定 self_signed_cert: true

      【讨论】:

        【解决方案3】:

        ssh+ssl ?

        但是从客户端的角度来看,这两者并没有关系(除非你想做某种ssh tunneling through NGiNX

        一个 ssh 连接将与 ssh 守护进程(不需要任何证书)对话,并要求正确的 ssh 公钥已注册到服务器帐户~/.ssh/authorized_keys(当用户注册时由 GitLab 完成)说 public键入他/她的个人资料页面)。

        gitlab-shell/bin/check 错误是另一个问题,同样与 ssh 问题无关。
        它是 gitlab-shell,它尝试通过 https API 联系本地 gitlab。
        在本地解决这个问题,来自客户端的任何连接(https 或 ssh)都会成功。

        特别是检查issues 3892,看看是否需要将CA 添加到NGiNX 提供的.crt 文件中。

        LJ Vankuiken 添加in the comments

        如果您的 gitlab 服务器提供的证书链无法被 gitlab-shell 完全验证,则需要将自签名标志设置为“true”。
        通过将签名机构的证书添加到系统证书存储区,我能够将自签名标志设置为“false”。

        【讨论】:

        • @user2530437 听起来不错。
        • “将 CA 添加到 .crt 文件”是什么意思?我有一个运行的 apache 服务器,它为我自己签署为 CA 的 crt 提供服务。 (不是自签名,我成了我自己的 CA。)我不确定你在 crt 中添加 CA 是什么意思
        • @snowe2010 那么你的证书是完整的,因为它是它自己的 CA。我的意思是,要使证书起作用,它需要由 CA 验证。
        • @VonC 所以即使我的证书不是自签名的(技术上)我还需要在 gitlab-shell 中启用自签名标志吗?
        • @snowe2010 实际上不确定,因为我只使用签名证书(自签名或由 CA 验证)
        【解决方案4】:

        为了万一有人遇到类似情况,我在端口 8080 上运行 Gitlab 并且因为 gitlab-shell/config.yml 中的 gitlab_url 没有指向端口 8080,所以它失败并出现重定向错误(我的服务器在该端口上运行) 80 开始了)。

        总结一下,如果您通过http://gitlab.mydomain.com:8080/ 访问gitlab,请确保gitlab_url 也指向http://gitlab.mydomain.com:8080/

        【讨论】:

          猜你喜欢
          • 2020-08-16
          • 1970-01-01
          • 1970-01-01
          • 2018-11-16
          • 2021-10-04
          • 1970-01-01
          • 1970-01-01
          • 2019-04-18
          相关资源
          最近更新 更多