1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/docs/sources
Alexander Larsson 05243104fc Add support for client certificates for registries
This lets you specify custom client TLS certificates and CA root for a
specific registry hostname. Docker will then verify the registry
against the CA and present the client cert when talking to that
registry.  This allows the registry to verify that the client has a
proper key, indicating that the client is allowed to access the
images.

A custom cert is configured by creating a directory in
/etc/docker/certs.d with the same name as the registry hostname. Inside
this directory all *.crt files are added as CA Roots (if none exists,
the system default is used) and pair of files <filename>.key and
<filename>.cert indicate a custom certificate to present to the registry.

If there are multiple certificates each one will be tried in
alphabetical order, proceeding to the next if we get a 403 of 5xx
response.

So, an example setup would be:
/etc/docker/certs.d/
└── localhost
    ├── client.cert
    ├── client.key
    └── localhost.crt

A simple way to test this setup is to use an apache server to host a
registry. Just copy a registry tree into the apache root, here is an
example one containing the busybox image:
  http://people.gnome.org/~alexl/v1.tar.gz

Then add this conf file as /etc/httpd/conf.d/registry.conf:

 # This must be in the root context, otherwise it causes a re-negotiation
 # which is not supported by the tls implementation in go
 SSLVerifyClient optional_no_ca

 <Location /v1>
 Action cert-protected /cgi-bin/cert.cgi
 SetHandler cert-protected

 Header set x-docker-registry-version "0.6.2"
 SetEnvIf Host (.*) custom_host=$1
 Header set X-Docker-Endpoints "%{custom_host}e"
 </Location>

And this as /var/www/cgi-bin/cert.cgi

 #!/bin/bash
 if [ "$HTTPS" != "on" ]; then
     echo "Status: 403 Not using SSL"
     echo "x-docker-registry-version: 0.6.2"
     echo
     exit 0
 fi
 if [ "$SSL_CLIENT_VERIFY" == "NONE" ]; then
     echo "Status: 403 Client certificate invalid"
     echo "x-docker-registry-version: 0.6.2"
     echo
     exit 0
 fi
 echo "Content-length: $(stat --printf='%s' $PATH_TRANSLATED)"
 echo "x-docker-registry-version: 0.6.2"
 echo "X-Docker-Endpoints: $SERVER_NAME"
 echo "X-Docker-Size: 0"
 echo

 cat $PATH_TRANSLATED

This will return 403 for all accessed to /v1 unless *any* client cert
is presented. Obviously a real implementation would verify more details
about the certificate.

Example client certs can be generated with:

openssl genrsa -out client.key 1024
openssl req -new -x509 -text -key client.key -out client.cert

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-06-13 11:13:18 +02:00
..
article-img Replacing ASCII art image with real diagram 2014-04-16 11:24:07 -04:00
articles Add support for client certificates for registries 2014-06-13 11:13:18 +02:00
contributing Update devenvironment.md 2014-05-04 17:52:48 +01:00
docker-hub Updated Docker Hub documentation 2014-06-08 18:01:44 -07:00
examples Initial links 2014-06-08 14:54:32 -07:00
installation Improve documentation on Ubuntu for getting the latest release of 2014-06-09 18:31:46 -07:00
introduction Fix some bullet points so they render correctly. 2014-06-11 11:44:30 +01:00
reference Fixed API 1.12 links and misc other fixes 2014-06-08 17:59:22 -07:00
static_files
terms Initial links 2014-06-08 14:54:32 -07:00
userguide minor spelling fix 2014-06-11 13:16:53 +02:00
articles.md Adding User Guide 2014-06-01 17:34:07 -04:00
contributing.md Docs auto-conversion fixes and MD marking and structure improvements. 2014-04-24 22:19:32 +10:00
examples.md Adding User Guide 2014-06-01 17:34:07 -04:00
faq.md Repaired broken links 2014-06-10 08:21:12 +03:00
genindex.md now, with shiney markdown 2014-04-16 11:04:14 +10:00
http-routingtable.md now, with shiney markdown 2014-04-16 11:04:14 +10:00
index.md Initial links 2014-06-08 14:54:32 -07:00
installation.md Added basic Debian installation page 2014-05-18 18:55:36 -04:00
jsearch.md move the documentation to markdown 2014-04-16 11:04:01 +10:00
reference.md Docs auto-conversion fixes and MD marking and structure improvements. 2014-04-24 22:19:32 +10:00
robots.txt move the documentation to markdown 2014-04-16 11:04:01 +10:00
search.md now, with shiney markdown 2014-04-16 11:04:14 +10:00
terms.md Docs auto-conversion fixes and MD marking and structure improvements. 2014-04-24 22:19:32 +10:00
toctree.md Docs auto-conversion fixes and MD marking and structure improvements. 2014-04-24 22:19:32 +10:00
use.md Add support for client certificates for registries 2014-06-13 11:13:18 +02:00