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

Commit eef7d1c

Browse files
committed
If REGISTRY_TLS_VERIFY is set, but GUNICORN_OPTS is not, serve TLS.
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 <[email protected]>
1 parent 1e4fca7 commit eef7d1c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

docker_registry/run.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import getpass
99
import logging
1010
import os
11+
import ssl
1112
import sys
1213

1314
from .server import env
@@ -84,7 +85,20 @@ def run_gunicorn():
8485
else:
8586
logger.warn('You asked we drop priviledges, but we are not root!')
8687

87-
args += env.source('GUNICORN_OPTS')
88+
gunicorn_opts = env.source('GUNICORN_OPTS')
89+
if not gunicorn_opts and env.source('REGISTRY_TLS_VERIFY'):
90+
gunicorn_opts = ['--ssl-version', ssl.PROTOCOL_TLSv1]
91+
for k, v in {
92+
'--certfile': '/ssl/registry.cert',
93+
'--keyfile': '/ssl/registry.key',
94+
'--ca-certs': '/ssl/ca.crt'
95+
}.iteritems():
96+
if not os.path.isfile(v):
97+
print("could not find %s" % (v))
98+
sys.exit(1)
99+
gunicorn_opts.append(k, v)
100+
101+
args += gunicorn_opts
88102
args.append('docker_registry.wsgi:application')
89103
# Stringify all args and call
90104
os.execl(*[str(v) for v in args])

0 commit comments

Comments
 (0)