您可以在 git 2.8(2016 年 3 月)中新的 curl 选项的实现中找到另一个示例:
See commit aeff8a6 https://github.com/git/git/commit/aeff8a61216bf6e0d663c08c583bc8552fa3c344 (15 Feb 2016) by Christoph Egger (siccegge) https://github.com/siccegge.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit e79112d https://github.com/git/git/commit/e79112d21024beb997951381db21a70b087d459d, 24 Feb 2016)
http
:实施公钥固定
Add the http.pinnedpubkey
公钥固定的配置选项。它允许任何支持的字符串libcurl
-- base64(sha256(pubkey))
or filename
的完整公钥。
如果 cURL 不支持固定(太旧),则会向用户输出警告。
The git config手册页 https://github.com/git/git/blob/aeff8a61216bf6e0d663c08c583bc8552fa3c344/Documentation/config.txt#L1682-L1688提到:
http.pinnedpubkey:
https 服务的公钥。
它可以是 PEM 或 DER 编码的公钥文件的文件名,也可以是以 ' 开头的字符串sha256//
' 后面是公钥的 Base64 编码 sha256 哈希值。
也可以看看libcurl 'CURLOPT_PINNEDPUBLICKEY' https://curl.haxx.se/libcurl/c/CURLOPT_PINNEDPUBLICKEY.html.
如果设置了此选项但 cURL 不支持,git 将退出并出现错误。
在 Git 2.34(2021 年第 4 季度)中,涉及 SSL 证书固定时,HTTPS 错误处理已更新:
See commit 3e8084f https://github.com/git/git/commit/3e8084f1884ffea25b80f76b7a1bd0e5b3200c8a (24 Sep 2021) by Ævar Arnfjörð Bjarmason (avar) https://github.com/avar.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 97492aa https://github.com/git/git/commit/97492aacffee48dd217164f6af4b9d1db1aa6646, 11 Oct 2021)
http https://github.com/git/git/commit/3e8084f1884ffea25b80f76b7a1bd0e5b3200c8a: check CURLE_SSL_PINNEDPUBKEYNOTMATCH
当发出错误时
Signed-off-by: Ævar Arnfjörð Bjarmason
更改出现错误时显示的错误http.pinnedPubKey
不匹配指向http.pinnedPubKey
变量添加到aeff8a6 https://github.com/git/git/commit/aeff8a61216bf6e0d663c08c583bc8552fa3c344 ("http
:实现公钥固定”,2016-02-15,Git v2.8.0-rc0 --merge https://github.com/git/git/commit/e79112d21024beb997951381db21a70b087d459d列于batch #8 https://github.com/git/git/commit/56f37fda511e1615dc6df86c68f3b841711a7828), e.g.:
git -c http.pinnedPubKey=sha256/someNonMatchingKey ls-remote https://github.com/git/git.git
fatal: unable to access 'https://github.com/git/git.git/' with http.pinnedPubkey configuration: SSL: public key does not match pinned public key!
在此之前,我们会发出完全相同的东西,而不需要“with http.pinnedPubkey configuration
".
这样做的好处是我们将收到翻译后的消息(“”之后的所有内容):
“ 是用英语硬编码的libcurl
),并且我们已经得到了对git-specific
导致错误的配置变量。
不幸的是,我们无法轻松测试这一点,因为没有任何测试需要https://
在测试套件中,以及t/lib-httpd.sh
不知道如何设置此类测试。
See 这个线程 https://lore.kernel.org/git/YUonS1uoZlZEt+Yd@coredump.intra.peff.net/开始讨论如何才能产生分歧”t/lib-httpd/apache.conf
“测试设置。