问题
I am trying to login to a company's private docker repository. When I try to login with:
docker login docker.abc.xyz.net
it returns only this error:
Error response from daemon: Get https://docker.abc.xyz.net/v1/users/: x509: certificate is valid for *.xyz.net, xyg.net, not docker.abc.xyz.net
We have a ca.cert
, which I have put at the following location:
/Users/myName/etc/docker/certs.d/docker.abc.xyz.net/ca.cert
I also tried putting it here:
/private/etc/docker/certs.d/docker.abc.xyz.net/ca.cert
and finally used this command to try to get keychain access for the cert:
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ca.crt
I even gave full access to the cert to see if that would be picked up. I have tried restarting docker as well, but nothing is accepting my certificate. Does anyone else have any ideas what might be preventing the login attempt on Docker Mac?
--------------
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
6c:ac:dd:00:bf:96:38:c3
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=ON DWCC Unclass Testing CA-1
Validity
Not Before: Jun 6 19:40:49 2016 GMT
Not After : Jun 6 19:40:49 2018 GMT
Subject: C=US, O=Navy, OU=ONI, CN=docker.abc.xyz.net
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (2048 bit)
Modulus (2048 bit):
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Subject Key Identifier:
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Authority Key Identifier:
keyid:
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Subject Alternative Name:
DNS:docker.abc.xyz.net
Signature Algorithm: sha256WithRSAEncryption
回答1:
This is actually correct, standards-compliant behavior. A *.xyz.net
wildcard certificate is valid for abc.xyz.net
or docker.xyz.net
, but not docker.abc.xyz.net
.
Quoting the answer to a question directly focused on this topic, in turn quoting RFC 2818:
Matching is performed using the matching rules specified by RFC2459. If more than one identity of a given type is present in the certificate (e.g., more than one dNSName name, a match in any one of the set is considered acceptable.) Names may contain the wildcard character
*
which is considered to match any single domain name component or component fragment. E.g.,*.a.com
matchesfoo.a.com
but notbar.foo.a.com
.f*.com
matchesfoo.com
but notbar.com
.
Consider adding an appropriate SubjectAltName to your certificate, if you can't regenerate it altogether.
来源:https://stackoverflow.com/questions/41289172/x509-certificate-is-valid-for-xyz-net-not-docker-abc-xyz-net