简体   繁体   English

docker登录失败-> x509:证书由未知授权签署。.“ crypto / rsa:验证错误”

[英]docker login fails -> x509: certificate signed by unknown authority .. “crypto/rsa: verification error”

I have created a private docker registry which is fronted by NGINX. 我已经创建了一个由NGINX代理的私有Docker注册表。 NGINX is where the ssl terminates. NGINX是ssl终止的位置。

I am obfuscating my domain by using my-domain.com for the purpose of this question. 为了解决这个问题,我使用my-domain.com来混淆我的域名。

I am using OSX 10.10.3 which has boot2docker installed. 我正在使用已安装boot2docker的OSX 10.10.3。 But it should be noted that the workflow of Vagrant + CoreOS + Docker shouldn't involve boot2docker since I am having issues within the VM(CoreOS) and not the Host(OSX). 但是应该注意,Vagrant + CoreOS + Docker的工作流不应该涉及boot2docker,因为我在VM(CoreOS)而不是Host(OSX)中遇到问题。

I am using Vagrant to spin up a local CoreOS VM from this box . 我正在使用Vagrant从此启动本地CoreOS VM。 I then ssh into an instance of that VM and attempt to issue the following command 然后,我将ssh放入该VM的实例,并尝试发出以下命令

$ docker login docker.my-domain.com

I am then prompted for my username, password, email as expected; 然后会提示我输入用户名,密码和电子邮件; and I supply my details. 并且提供我的详细信息。

Note: I am able to issue the above command in the Host OS (OSX) as expected and able to successfully login (generates the ~/.dockercfg file). 注意:我能够按预期在主机OS(OSX)中发出上述命令,并能够成功登录(生成〜/ .dockercfg文件)。

I get the following error: 我收到以下错误:

FATA[0008] Error response from daemon: v1 ping attempt failed with error: Get https://docker.my-domain.com/v1/_ping: 
x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to 
verify candidate authority certificate "*.my-domain.com"). If this private registry supports only HTTP or HTTPS 
with an unknown CA certificate, please add `--insecure-registry docker.my-domain.com` to the daemon's 
arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; 
simply place the CA certificate at /etc/docker/certs.d/docker.my-domain.com/ca.crt

I have copied over my ca.crt from my self signing. 我已经从我的自签名中复制了我的cart。 I can confirm that CoreOS is able to connect properly to my server over SSL. 我可以确认CoreOS能够通过SSL正确连接到我的服务器。 I ran this command 我跑了这个命令

openssl s_client -CAfile /etc/docker/certs.d/docker.my-domain.com/ca.crt -connect docker.my-domain.com:443

And I get the expected 'Verify return code: 0 (ok)'. 然后我得到了预期的“验证返回码:0(确定)”。 This leads me to believe its docker that seems to be having a problem. 这使我相信它的docker似乎有问题。

$ docker version (from within CoreOS VM)
Client version: 1.6.1-rc2
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 17f157d-dirty
OS/Arch (client): linux/amd64
Server version: 1.6.1-rc2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 17f157d-dirty
OS/Arch (server): linux/amd64

After all this, I am not sure what I need to try next. 毕竟,我不确定接下来需要尝试什么。 Any and all help is appreciated! 任何和所有帮助表示赞赏!

This turned out to be a two part issue. 事实证明这是一个两部分的问题。 The first issue was that when I placed the certificate file(ca.crt) in the relative /etc/ssl/certs/ folder, I didn't rename the original file with the .pem extension. 第一个问题是,当我将证书文件(ca.crt)放在相对的/ etc / ssl / certs /文件夹中时,我没有使用.pem扩展名重命名原始文件。 This meant that when I ran the the update-ca-certificates to install my custom certificate on the client machine, it wasn't getting recognized. 这意味着当我运行update-ca-certificates在客户端计算机上安装我的自定义证书时,该证书未被识别。 This was hiding the second and main issue. 这是第二个主要问题。

I wasn't using the correct certificate file. 我没有使用正确的证书文件。 Once I used the correct certificate file, and I renamed the file to have the .pem extension I ran update-ca-certificates and then issued the login command and it worked. 一旦我使用了正确的证书文件,并且将文件重命名为.pem扩展名,我就运行了update-ca-certificates,然后发出了login命令,它就起作用了。

I assume I mush have installed the correct version of the cert correctly on my host OSX machine, which is why it worked there but not in the VM. 我假设我必须在主机OSX机器上正确安装了正确版本的证书,这就是为什么它可以在那儿工作但不在VM中工作的原因。

This is mostly useful for other people running into this.. If you are using intermediate certificates, the ca.pem file that docker sees MUST have both the root and the intermediate certificates in it. 这对于遇到此问题的其他人来说非常有用。如果您使用的是中间证书,则docker认为ca.pem文件必须同时具有根证书和中间证书。 If you are using client certs, you almost certainly want the full cert chain in your ~/.docker/ca.pem file as well. 如果您使用的是客户端证书,那么几乎可以肯定,您也希望〜/ .docker / ca.pem文件中包含完整的证书链。

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

相关问题 无法在 macOS 上使用 podman 登录 docker 注册表 - x509:证书由未知机构签名 - Unable to login to docker registry using podman on macOS - x509: certificate signed by unknown authority Helm3 Kubernetes 集群无法访问 - x509:证书由未知权威签署 - Helm3 Kubernetes cluster unreachable - x509: certificate signed by unknown authority 此证书由未知权限的钥匙串签名 - This certificate was signed by unknown authority keychain CSSMERR_TP_NOT_TRUSTED:WWDR证书-该证书由未知授权机构签名 - CSSMERR_TP_NOT_TRUSTED: WWDR certificate - this certificate was signed by an unknown authority Docker error "https://registry-1.docker.io/v2/": x509 certifacte not valid for registry-1.docker.io in macOS - Docker error "https://registry-1.docker.io/v2/": x509 certifacte not valid for registry-1.docker.io in macOS 为在 OS X 上导入钥匙串的 X509 CA 证书添加信任 - Adding trust for a X509 CA certificate imported into keychain on OS X Golang x509无法在Mac OS X上加载系统根目录错误 - Golang x509 Failed to load system roots error on Mac OS X MacO上的证书验证失败 - Certificate verification fails on MacOs 在Mac钥匙串访问中向证书颁发机构请求证书时出错 - Error to Request a Certificate From a Certificate Authority on Mac Keychain Access 创建证书时发生未知错误 - Unknown Error Creating a certificate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM