Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
If REGISTRY_TLS_VERIFY is set, but GUNICORN_OPTS is not, then serve via
Browse files Browse the repository at this point in the history
a TLS endpoint instead of plain HTTP.

This is done by setting GUNICORN_OPTS to some default value, expecting
the following files to be present:

* /ssl/ca.crt
* /ssl/registry.cert
* /ssl/registry.key

Signed-off-by: Tibor Vass <teabee89@gmail.com>
  • Loading branch information
tiborvass committed Nov 10, 2014
1 parent 1e4fca7 commit 8aa5c8d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docker_registry/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import os
import sys
import ssl

from .server import env

Expand Down Expand Up @@ -84,7 +85,16 @@ def run_gunicorn():
else:
logger.warn('You asked we drop priviledges, but we are not root!')

args += env.source('GUNICORN_OPTS')
gunicorn_opts = env.source('GUNICORN_OPTS')
if not gunicorn_opts and env.source('REGISTRY_TLS_VERIFY'):
gunicorn_opts = ['--ssl-version', ssl.PROTOCOL_TLSv1]
for k, v in {'--certfile':'/ssl/registry.cert', '--keyfile':'/ssl/registry.key', '--ca-certs':'/ssl/ca.crt'}.iteritems():
if not os.path.isfile(v):
print("could not find %s" % (v))
sys.exit(1)
gunicorn_opts.append(k, v)

args += gunicorn_opts
args.append('docker_registry.wsgi:application')
# Stringify all args and call
os.execl(*[str(v) for v in args])

0 comments on commit 8aa5c8d

Please sign in to comment.