ssl - git 不能完全使用自签名证书

标签 ssl gitlab

我使用自签名证书进行加密。
经过一些工作后,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 时您也将 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

关于ssl - git 不能完全使用自签名证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17356972/

相关文章:

cron - manbetx客户端打不开备份不包括维基

docker - Gitlab链接到 “https://gitlab/”

PostgreSQL:后台 worker "logical replication launcher"已退出,退出代码为 1

go - 私有(private)仓库 - go 1.13 - `go mod ..` 失败 : ping "sum.golang.org/lookup" . 。正在验证包.. 410 消失了

HTTPS 与 HTTP 和 livehttpheaders

Java SSL socket -- 客户端证书证明

PHP/JavaScript 检查 SSL

maven - Gitlab ci 代码质量: This GitLab CI configuration is invalid

python - 如何在python3中使用sslscan

java - 在反向代理后面访问 ElastiC