New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x509: certificate is not valid for any names, but ... #248
Comments
Could the registry be redirecting to an auth server, for which that certificate may not be valid? For example: https://docs.docker.com/registry/spec/auth/token/#requesting-a-token. Is that a possibility, or is it just htpasswd? |
There is no redirect and only Basic Auth. I can reproduce this on a plain Centos 7 installation without modifications. Attached the Vagrant file and some bootstrap script to recreate the VM. Vagrantfile
bootstrap.sh
The error occurs even without the CA certificate, means before the certificate chain is validated. |
Did some further research and changed the bootstrap.sh to not install the latest docker-ce version, but 17.09. Now everything works as expected. (after manually add the CA certificate)
docker version
Where is the difference between docker-ce 17.12 and 17.09? The GO version (1.8.3 vs. 1.9.4)? |
@gibma Thanks for trying all of this out and providing the vagrant info! I tested your vagrant setup against a registry I spun up with a self-signed CA-signed server cert, and I am not getting the same error, so we may have to just dig into the code some more to see where else it may be making connections. I just wanted to comment so you know you are not being ignored. |
@cyli Thank you for taking care of it. I do not want to rule out that our certificate is the cause, but I have no idea how to figure this out. Unfortunately, I can not provide it for privacy reasons, and our registry is not accessible from the Internet anyway. If I can help in any way to find the cause, let me know |
Argh... Found it. The problem is not with Docker, but with golang. I will create an issue there. Our certificate has the following attributes:
(http://www.alvestrand.no/objectid/2.5.29.17.html) So when docker (17.12) is verifying the certificate, the following golang (1.9) code is executed: (https://github.com/golang/go/blob/release-branch.go1.9/src/crypto/x509/verify.go)
It checks if the extension is present (it is), and joins the alternate DNSNames (which we don't have, only IP-Addresses). So after this, valid is empty an the error is thrown. 👎 These lines of code have actually changed between golang 1.8 and golang 1.9. In golang 1.8, the following was executed:
Here, the if clause does not match, and the c.Subject.CommonName is used. (and is valid). 👍 Therefore this issue can be closed. Thanks for your support! |
Thanks so much for digging into this @gibma! I'll close the issue then. |
I now realize that the Kubernetes CLI documentation is rather inconsistent. I'm also realizing they're in the middle of both migrating away from CLI options and adding more CLI options depending on what daemon you are looking at. Normalizing to the (now deprecated) `--kubeconfig` option seems to get most daemons commmunicating with the apiserver via TLS. There's also a fun bug detailed by a glorious Github user that says `Go` will ignore a certificate's DN if any SAN is provided with the certificate. Since some Kubernetes daemons require an IP SAN on the certificate, I also need to add the hostname under a DNS SAN. docker/for-linux#248 (comment)
Expected behavior
docker login https://our.company.registry:5000
with self signed server certificate will succeed.Actual behavior
Got error message:
Error response from daemon: Get https://our.company.registry:5000/v2/: x509: certificate is not valid for any names, but wanted to match our.company.registry
I checked the CA and server certs several times with multiple tools. Everything is valid and contents look fine. CN is properly set. I have also written a small GO script, making a TLS connection to the given host with no such error message.
Trying
curl https://our.company.registry:5000/v2/ --cacert /etc/docker/certs.d/our.company.registry:5000/ca.crt
also works well:Turning on logging and debug for docker engine gave no more helpful information.
Digging into the GO x509 source code reveals no hint, why there shouldn't be any names in the server certificate.
Steps to reproduce the behavior
According to https://docs.docker.com/engine/security/certificates/
Add CA certificate to
/etc/docker/certs.d/our.company.registry:5000/ca.crt
Execute
docker login
with username and password.Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.)
The text was updated successfully, but these errors were encountered: