You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法从PC推送至GitHub:SSL证书问题求助

Fixing "SSL certificate problem: self-signed certificate in certificate chain" When Pushing to GitHub

Hey there! Since you're a Git/GitHub newbie and previously could push code without issues, this sudden SSL error is likely due to a change in your network or system environment—like a new router with SSL inspection, antivirus software intercepting connections, or a subtle Git config tweak. Let's walk through simple, step-by-step solutions tailored for your Windows 10 + Git Bash setup:

1. First: Test if SSL Verification is the Culprit (Temporary Fix)

This is a quick check to confirm the issue ties to SSL certificates. Don't use this long-term (it disables important security checks), but it'll help narrow things down:

  • Run this command in Git Bash:
    git config --global http.sslVerify false
    
  • Try pushing your code again with git push. If it works, you've confirmed the problem is SSL certificate-related.
  • Remember to re-enable SSL verification afterward to keep your connections secure:
    git config --global http.sslVerify true
    

This tells Git to explicitly trust GitHub's valid certificate, resolving the chain mismatch:

  1. Export GitHub's certificate:
    • Open your browser, go to github.com. Click the lock icon in the address bar → "Certificate (Valid)" → "Details" tab → "Copy to File..."
    • Choose "Base64 encoded X.509 (.CER)" as the format, save it as github.crt somewhere easy to find (like your Documents folder).
  2. Configure Git to use the certificate:
    • In Git Bash, run this command (replace the path with where you saved github.crt):
      git config --global http.sslCAInfo "C:/Users/YourUsername/Documents/github.crt"
      
    • Try pushing again. This should fix the issue without sacrificing security.

3. Check for Antivirus/Firewall SSL Interception

Many antivirus tools or home routers use "SSL scanning" which inserts a self-signed certificate into your connection. This confuses Git because it doesn't recognize the certificate:

  • Temporarily disable SSL scanning features in your antivirus software (look for terms like "web protection" or "SSL inspection").
  • If you have a custom router, check its settings for any SSL filtering options and disable them temporarily.
  • Try pushing again. If it works, add github.com to your antivirus/router's trusted sites list to keep protection enabled while avoiding the error.

4. Switch to SSH Protocol (Alternative Fix)

If HTTPS keeps giving you trouble, switching to SSH is a reliable alternative—and it avoids password prompts once set up:

  1. Generate an SSH key:
    • In Git Bash, run this (replace with your GitHub email):
      ssh-keygen -t ed25519 -C "your_email@example.com"
      
    • Press Enter three times to accept default settings (no passphrase unless you want an extra layer of security).
  2. Add the key to GitHub:
    • Open the public key file in Git Bash:
      cat ~/.ssh/id_ed25519.pub
      
    • Copy the entire output (starts with ssh-ed25519).
    • Go to GitHub → Click your profile picture → Settings → SSH and GPG keys → New SSH key.
    • Paste the key, give it a name (like "Windows Git Bash"), and save.
  3. Update your remote repository URL:
    • Replace the HTTPS URL with SSH in Git Bash:
      git remote set-url origin git@github.com:myusername/my-repo.git
      
    • Now try git push again—this should work without SSL issues.

内容的提问来源于stack exchange,提问作者Shadow43375

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:40:08