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

Commit 8aa5c8d

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

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docker_registry/run.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import logging
1010
import os
1111
import sys
12+
import ssl
1213

1314
from .server import env
1415

@@ -84,7 +85,16 @@ 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 {'--certfile':'/ssl/registry.cert', '--keyfile':'/ssl/registry.key', '--ca-certs':'/ssl/ca.crt'}.iteritems():
92+
if not os.path.isfile(v):
93+
print("could not find %s" % (v))
94+
sys.exit(1)
95+
gunicorn_opts.append(k, v)
96+
97+
args += gunicorn_opts
8898
args.append('docker_registry.wsgi:application')
8999
# Stringify all args and call
90100
os.execl(*[str(v) for v in args])

0 commit comments

Comments
 (0)