【问题标题】:git client and browser separation on https serverhttps服务器上的git客户端和浏览器分离
【发布时间】:2017-01-03 22:12:31
【问题描述】:

我正在尝试为 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_clientgit clone 的证书不同。我可以在转储中看到的唯一区别(在客户端问候中)是:anongit.gentoo.org 的 SNI 和 git 流量中的 http/1.1 的 ALPN。 git客户端和浏览器的区别似乎太少了。

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

【问题讨论】:

    标签: git ssl curl https pinning


    【解决方案1】:

    显然,这里的差异制造者是 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一起使用的。

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

    【讨论】:

      猜你喜欢
      • 2018-03-04
      • 1970-01-01
      • 2015-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-10
      • 2018-02-24
      • 1970-01-01
      相关资源
      最近更新 更多