2

我正在尝试为git clone. 为了做到这一点,我使用openssl s_client并从服务器 hello 中获取了证书:

openssl s_client -connect anongit.gentoo.org:443 2>&1 </dev/null

但是下面的命令在服务器证书检查上实际上是失败的:

git clone -c http.sslVerify=yes -c 'http.pinnedpubkey=sha256//13fY3xnMhZp6C5wKICfMZVJbN+AtmBbTXSy+sjJvKDE=' https://anongit.gentoo.org/git/repo/gentoo.git

做了一些调查,我在网络转储中发现openssl s_client和的证书不同git clone。我可以在转储中看到的唯一区别(在客户端打招呼中)是:SNI 用于流量anongit.gentoo.org,ALPN 用于http/1.1流量git。区分git客户端和浏览器似乎太少了。

所以,问题是:服务器如何准确地检测到git客户端以便使用不同的证书进行回复?

4

1 回答 1

0

显然,这里的差异制造者是 SNI:

openssl s_client -connect anongit.gentoo.org:443 2>&1 </dev/null | sed -n '/BEGIN/,/END/p'  | openssl x509 -noout -pubkey | openssl rsa -pubin -outform DER | openssl dgst -sha256 -binary | openssl enc -base64

openssl s_client -servername anongit.gentoo.org -connect anongit.gentoo.org:443 2>&1 </dev/null | sed -n '/BEGIN/,/END/p'  | openssl x509 -noout -pubkey | openssl rsa -pubin -outform DER | openssl dgst -sha256 -binary | openssl enc -base64

这些命令返回不同的证书哈希(相应地不使用和使用 SNI)。第二个是与git clone.

尽管如此,这样做的真正原因对我来说仍然是个谜。

于 2016-08-27T10:20:36.600 回答