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

配置SSH Key后使用GitBash推送公司GitLab仓库时出现SSL证书问题求助

Fixing "SSL certificate problem: unable to get local issuer certificate" When Pushing to GitLab

Hey there, let's break this down for you—first, let's clear up a critical misunderstanding:

SSH and HTTPS are two totally separate ways to connect to Git repositories. Your SSH Key configuration is working independently, but the error you're hitting means your Git client is trying to use the HTTPS protocol to talk to GitLab, which requires valid SSL certificate verification. Since you already set up SSH keys, switching to the SSH protocol is the easiest fix.


Step 1: Check Your Remote Repository URL

First, confirm which protocol your local repo is using. Run this in Git Bash:

git remote -v
  • If the output shows URLs starting with https://, that's why you're seeing the SSL error—you're using HTTPS instead of SSH.
  • If URLs start with git@gitlab.com:, you're already using SSH (and this error shouldn't occur, so feel free to comment with more details if that's your case).

Since you've already configured your SSH Key, update your remote repo URL to use SSH with this command (replace the placeholder with your actual repo path):

git remote set-url origin git@gitlab.com:your-username/your-repository.git

Once you run this, try pushing again—your SSH Key will handle authentication, and the SSL certificate error will disappear entirely.


If You Need to Stick With HTTPS: Fix the SSL Certificate Issue

If HTTPS is a must for your workflow, here's how to resolve the certificate problem properly:

Option 1: Temporarily Disable SSL Verification (Testing Only)

Run this command to turn off global SSL validation (note: this reduces security, so only use it to confirm the issue):

git config --global http.sslVerify false

If your push works after this, you've confirmed the problem is certificate-related.

Option 2: Install the GitLab Root Certificate (Permanent, Secure Fix)

  1. Export the root certificate: Go to your GitLab instance in a web browser, click the padlock icon in the address bar, and export the root SSL certificate as a .crt file.
  2. Store the certificate: Place the .crt file in a safe location—your ~/.ssh folder is a good choice since you already manage SSH-related files there.
  3. Configure Git to use the certificate: Run this command (adjust the file path to match where you saved the certificate):
    git config --global http.sslCAInfo "C:/Users/YourUsername/.ssh/gitlab-root-cert.crt"
    
    (On Windows, use forward slashes or double backslashes; on macOS/Linux, use a path like ~/.ssh/gitlab-root-cert.crt.)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 01:52:40