2

【茶包射手日記】WSL Git 憑證驗證無效錯誤

 1 year ago
source link: https://blog.darkthread.net/blog/wsl2-git-cert-issue/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【茶包射手日記】WSL Git 憑證驗證無效錯誤

calendar.svg 2023-07-16 03:10 PM comment.svg 1 eye.svg 1,109

微軟推出 WSL2 好一陣子了,與前一代 WSL 相比有革命性的進化,WSL2 包含完整的 Linux 核心、支援完整的系統 API、檔案效能大幅提升,並能與 Windows 無縫整合,我只有去年底小試了一下,平日工作或研究沒什麼機會用到。前幾天看到網友分享用 WSL 直接編譯單晶片模組的韌體,提醒我 WSL2 的好用之處。單晶片程式的原始碼及編譯多半要使用 Linux 環境,硬搬到 Windows 環境編譯有太多魔王要打,對我這種 C 語言麻瓜難如登天,網路上也很難找到教學,直接在 Linux 環境編譯省事的明確選擇。過往我會建台 Hyper-V Linux VM 處理,現在有了 WSL2 可更充分發揮個人電腦效能,又能與本機檔案系統無縫整合,完勝獨立 Linux VM。

不過呢,才試了第一行指令我就踩到雷。git clone 出現 fatal: unable to access 'https://salsa.debian.org/gnuk-team/gnuk/gnuk.git/': server certificate verification failed. CAfile: none CRLfile: none 錯誤訊息。

Fig1_638250883119836586.png

我第一時間是懷疑網站的 TLS 憑證本身有問題,但用瀏覽器檢視是 Let's Encrypt 憑證,不管到期日或簽核者都是有效的。

Fig2_638250883123324752.png

想起前幾天看到的新聞,Let's Encrypt 憑證原本有用 IdenTrust DST Root CA X3 做跨簽章(Cross-Signing)以確保各家瀏覽器及 Android 手機能正確驗證,由於 Let's Ecnrypt 自家根憑證已受到廣泛信任,故 2024/2/8 起的新憑證將不再跨簽章以節省費用,雖然時間點對不上,但直覺有點相關。

又做了測試,我發現兩件事: 在 WSL 用 curl 存取同一網站並未發生憑證錯誤、有問題的 /usr/bin/git 版本為 2.25.1 偏舊,Windows 的 git.exe 為 2.38.1 clone 該專案正常。

Fig3_638250883125206006.png

決定更新 git 版本試試,更新前先跑了 sudo apt-get update && sudo apt-get upgrade 更新 Ubuntu 作業系統,發現 git 2.25.1 還沒升級新版憑證問題已消失! 這批 Ubuntu 升級項目近 500 項,不確定是哪部分更新解決了問題,但學到經驗,跟 Windows 一樣:遇到疑難雜症,先確認作業系統有更新到最新版本,省下跟已修正問題打架的時間。

【同場加映】Git 還是該升級到新版功能更齊全。查了一下,Ubuntu 官方提供的 Git 版本偏舊,要更新到最新版要靠 PPA (Personal Package Archives):參考

sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
git --version

新增 Git PPA 來源、apt-get update、再次安裝 git 就會成功升級到 2.41.0 囉~

and has 1 comment

Comments

Post a comment

Comment
Name Captcha 61 + 34 =

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK