zaki work log

作業ログやら生活ログやらなんやら

プライベートなGitLab CE(HTTPS動作)へのGit操作の証明書設定

プライベートネットワーク上でHTTPSで動かしているオレオレ証明書なGitLab CEのGitリポジトリにアクセスすると

$ git clone https://gitlab-ce.example.org:8443/zaki/example.git
Cloning into 'example'...
fatal: unable to access 'https://gitlab-ce.example.org:8443/zaki/example.git/': Peer's certificate issuer has been marked as not trusted by the user.

となります。

自己署名の証明書なので、ちゃんと設定しないとエラーになってしまう。 証明書検証をオフにすれば動くといえば動くけど、ちゃんと設定してみる。

サーバ側の設定はこれ

zaki-hmkc.hatenablog.com

前回Dockerの設定に証明書追加しているので、同じものを使う。 別のホストであれば、それっぽい場所にcrtファイルを配置してそれを指定すればOK。

$ git config --global http.sslCAInfo /etc/docker/certs.d/gitlab-ce.example.org\:25000gitlab-ce.example.org.crt

できた設定ファイル

$ cat ~/.gitconfig
[http]
        sslCAInfo = /etc/docker/certs.d/gitlab-ce.example.org:25000/gitlab-ce.example.org.crt

設定できたらGit操作してみる。

$ git clone https://gitlab-ce.example.org:8443/zaki/example.git
Cloning into 'example'...
Username for 'https://gitlab-ce.example.org:8443': zaki
Password for 'https://zaki@gitlab-ce.example.org:8443': 
warning: You appear to have cloned an empty repository.

まだ何もデータがなかったけど、アクセスはできました。

$ git commit -m "initial commit"
[master (root-commit) c3baf65] initial commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
$ git push -u origin master
Username for 'https://gitlab-ce.example.org:8443': zaki
Password for 'https://zaki@gitlab-ce.example.org:8443':
Counting objects: 3, done.
Writing objects: 100% (3/3), 210 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://gitlab-ce.example.org:8443/zaki/example.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

ちゃんとpushもできてる。