[Mac] 將 mitmproxy Root CA 憑證加入信任清單

[Mac] 將 mitmproxy Root CA 憑證加入信任清單

之前有 使用 mitmproxy 監看 HTTPS 的連線內容

不過那時候沒有信任 mitmproxy 自己產生的 CA 憑證,

所以 curl 都得加 -k 選項忽略 TLS 驗證才行~

不過每次都得加,有點麻煩,

所以就還是來把 mitmproxy 的 Root CA 加入信任清單吧~

 

在 Mac 上執行下面的指令:

sudo security add-trusted-cert -d -p ssl -p basic -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pem

 

加入成功之後,在 Keychain Access app > System > Certificates 裡面,

應該可以找到 mitmproxy 這張 Root CA 憑證:

 

再來試試看 curl 指令,這次不用加上 -k 選項,也能正常連上 Google 了:

$ curl -Lv -x http://127.0.0.1:8080 https://www.google.com

*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.79.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
......
* Server certificate:
*  subject: CN=www.google.com
*  start date: Jun 15 01:14:06 2022 GMT
*  expire date: Jun 17 01:14:06 2023 GMT
*  subjectAltName: host "www.google.com" matched cert's "www.google.com"
*  issuer: CN=mitmproxy; O=mitmproxy
*  SSL certificate verify ok.
......
< HTTP/2 200

 

這樣以後使用 mitmproxy + curl 就更加方便啦~

 

參考資料:mitmproxy certificates

(本頁面已被瀏覽過 307 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料