简体   繁体   English

在 mac git 上克隆 https 无法验证

[英]on mac git clone over https fails to authentication

On a mac mini with Mavericks I am having problems authenticating when I try to git clone from a private git server.在带有 Mavericks 的 mac mini 上,当我尝试从私有 git 服务器克隆 git 时,我在验证时遇到了问题。 I have installed and configured git on Windows and Ubuntu a few times with this same server and haven't this sort of problem before.我已经使用同一台服务器在 Windows 和 Ubuntu 上安装和配置了 git 几次,之前没有出现过此类问题。 I'm at a loss as to what to try next.我不知道接下来要尝试什么。

Symptoms:症状:

git clone https://username@git.example.com:8448/git/libs/project.git
Cloning into 'project' ...
Password for 'https://username@git.example.com:8448': [1] note
fatal: Authentication failed for 'https://username@git.example.com:8448/git/libs/project.git'

[1] I am not asked for this on other systems. [1] 我在其他系统上没有被要求这样做。 I believe I have configured my git client to not ask for passwords.我相信我已经将我的 git 客户端配置为不要求输入密码。 No password I provide is good at this prompt No password I provide 好在这个提示

I have this in my ~/.gitconfig:我的 ~/.gitconfig 中有这个:

[http]
        sslKey = /Users/macuser/auth/username.key
        sslCert = /Users/macuser/auth/username.pem
        sslVerify = false
[user]
        name = username
        email = username@example.com

I received the following files when setting up my client certificates which I placed in a folder named ~/auth:在设置我的客户端证书时,我收到了以下文件,我将它们放在名为 ~/auth 的文件夹中:

username.cer用户名.cer
username.p12用户名.p12
username.pem用户名.pem
ca.cer癌症

I ran this command to generate the key file:我运行了这个命令来生成密钥文件:

openssl rsa -in /Users/macuser/auth/username.pem -out /Users/macuser/auth/username.key

And then I ran git config commands such as:然后我运行 git 配置命令,例如:

git config --global http.sslKey /Users/macuser/auth/username.key
git config --global http.sslCert /Users/macuser/auth/username.pem
git config --global http.sslVerify false

After configuring git just like the steps above, on other systems when I do a 'git clone https' it just works.像上面的步骤一样配置 git 后,在其他系统上,当我执行“git clone https”时,它就可以工作了。 On OS X Mavericks with Xcode command line tools installed, git cannot authenticate.在安装了 Xcode 命令行工具的 OS X Mavericks 上,git 无法进行身份验证。

What am I doing wrong?我究竟做错了什么?

Thanks in advance.提前致谢。

Edit:编辑:

I thought I'd add this piece of information.我想我会添加这条信息。 The server is using a self signed certificate, or one which comes from no authority.服务器使用的是自签名证书,或者来自非权威机构的证书。 This is why I set http.sslVerify to false.这就是我将 http.sslVerify 设置为 false 的原因。

Here are the verbose clone commands.这是详细的克隆命令。 The setups on Linux and Mac are the same, save for auth folder locations. Linux 和 Mac 上的设置相同,除了 auth 文件夹位置。 The Linux version succeeds while the Mac version fails. Linux版本成功,Mac版本失败。

http://cache.codebot.org/stackoverflow/linux-git-works.txt http://cache.codebot.org/stackoverflow/linux-git-works.txt
http://cache.codebot.org/stackoverflow/mac-git-fails.txt http://cache.codebot.org/stackoverflow/mac-git-fails.txt

Answer:回答:

sudo port install git-core

解决方案是使用 git 的 macports 版本,而不是使用 Xcode 命令行工具附带的版本。

sudo port install git-core

when you try to use git clone and if its prompt for password please provide the git personal access token here当您尝试使用 git clone 并且提示输入密码时,请在此处提供 git 个人访问令牌

that will resolve the issue.这将解决问题。

sslVerify false ? sslVerify false Then you desactivate completely the certificate verification by curl.然后您通过 curl 完全停用证书验证。

You can have more details with:您可以通过以下方式获得更多详细信息:

GIT_CURL_VERBOSE=1 git clone https://...

Check if the other systems don't have a %HOME%/_netrc (Windows) or ~/.netrc (unix) with your credentials in it, which would explain why you don't have to enter a password there.检查其他系统是否没有包含您的凭据的%HOME%/_netrc (Windows) 或~/.netrc (unix),这将解释为什么您不必在那里输入密码。

In your case, it is possible the CA and other root certificates used in Linux in /etc/ssl/certs/ca-certificates.crt aren't present on mac.在您的情况下,/ /etc/ssl/certs/ca-certificates.crt certificates.crt 中 Linux 中使用的CA和其他根证书可能不存在于 mac 上。
Try to add the content of that Linux file to the git cert file on the client side on your <path/to/git/bin/curl-ca-bundle.crt> file, a bit like in this solution .尝试将该 Linux 文件的内容添加到客户端的<path/to/git/bin/curl-ca-bundle.crt>文件中的 git cert 文件中,有点像这个解决方案

The OP sysrpl reports though that it isn't necessary, since sysrpl had to do a: OP sysrpl报告虽然没有必要,因为 sysrpl 必须执行以下操作:

sudo port install git-core

to update/reset the git installation on the Mac.在 Mac 上更新/重置 git 安装。

Instead of using a GitHub account password, use a GitHub access token to resolve the issue.不要使用 GitHub 帐户密码,而是使用 GitHub 访问令牌来解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM