Visual Studio中Git推送SSL证书错误求助:无法获取本地颁发者证书
Hey there, let's work through this SSL certificate issue you're facing when pushing to your Azure DevOps Git repo. It's weird that your browser and Visual Studio can connect just fine but Git throws this error—usually, this happens because Git isn't using the same trusted certificate store as those apps. Here are a few solid fixes to try:
1. Use Windows' SSL Channel (Recommended for Windows Users)
Since Visual Studio and your browser rely on Windows' built-in certificate store, you can tell Git to do the same with this command:
git config --global http.sslBackend schannel
This makes Git use the Windows Secure Channel API instead of its own OpenSSL setup, so it'll automatically trust the certificates your system already recognizes. No need to manually copy any certs!
2. Manually Import the Root CA Certificate
If the first fix doesn't work, you can explicitly tell Git to trust the root certificate from your Azure DevOps server:
- Open your browser, navigate to your Azure DevOps repo URL, and click the lock icon in the address bar.
- View the certificate details, find the root CA certificate (the top-level one in the certificate chain), and export it as a Base64-encoded
.crtfile. - Run this command, replacing the path with where you saved your exported cert:
(Use forward slashes or double backslashes for Windows paths to avoid issues.)git config --global http.sslCAInfo "C:/Users/YourName/Documents/root-cert.crt"
3. Temporarily Disable SSL Verification (Not Recommended for Production)
If you just need to push a change quickly and can't fix the cert issue right away, you can turn off SSL verification temporarily. Note: This is insecure and should only be used for testing!
git config --global http.sslVerify false
Once your push goes through, remember to re-enable verification with:
git config --global http.sslVerify true
Check Your Git SSL Configuration
To confirm your changes took effect, run this command to see all global SSL-related settings:
git config --list --global | grep ssl
内容的提问来源于stack exchange,提问作者udaya726

