[英]Adding self-signed SSL certificate without disabling authority-signed ones
我有一個公司git服務器,使用自簽名證書通過https工作。 本地克隆包含兩個遠程服務器,一個是指向該服務器的遠程主機,另一個是指向github的遠程主機。 默認情況下,從原點提取失敗:
$ git pull
fatal: unable to access 'https://user@code.example.com/git/fizzbuzz.git/': SSL certificate problem: self signed certificate
github遠程工作正常。
通常有兩種建議的解決方案:
git config http.sslVerify false
這是個壞主意,建議將Git配置為接受特定https遠程服務器的特定自簽名服務器證書 :
git config http.sslCAInfo <downloaded certificate>.pem
修復了從原點拉出的問題,但破壞了github遠程:
$ git pull github
fatal: unable to access 'https://github.com/user/fizzbuzz.git/': SSL certificate problem: unable to get local issuer certificate
如何在不中斷從github的情況下使從公司服務器中拉取工作?
如果您使用的是Git 1.8.5+(2013年8月),則可以為每個URL(!)指定http指令 。
在您的情況下:
git config --global http."https://code.example.com/".sslVerify false
#
# or, if not on default 443 port:
#
git config --global http."https://code.example.com:<aPort>/".sslVerify false
這將僅對code.example.com
而不對其他URL禁用SSL驗證。
要么:
git config --global http."https://code.example.com/".sslCAInfo <downloaded certificate>.pem
相同的想法: sslCAInfo
僅針對code.example.com
URL指向<downloaded certificate>.pem
。
可以在Git系統證書存儲中添加證書,使用git-for-windows可以在C:\\path\\to\\PortableGit-2.6.1-64-bit\\usr\\ssl\\certs\\ca-bundle.crt
。
但是,這不是最佳實踐,除非您必須分發包含內部證書的Git發行版。
從Windows的Git v2.5.0(git-for-windows.github.io)開始,已安裝的證書文件已移至“ C:\\ Program Files(x86)\\ Git \\ mingw32 \\ ssl \\ certs \\ ca-bundle。 crt”。 您必須將證書添加到此文件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.