This repository has been archived by the owner on Sep 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable TLS by default if /ssl directory is present.
Generates needed keys and certs. If only one element in the key/cert pair is present, nothing is overriden; instead, the user is asked to either remove the existing element, or put the missing one back. Uses TLSv1, since TLSv1.1 nor TLSv1.2 are available in the current version of python 2.7. Usage: docker run -d -p 5000:5000 -v /etc/docker/certs.d:/ssl registry There are no breaking changes, since the /ssl directory is not present by default. Signed-off-by: Tibor Vass <teabee89@gmail.com>
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
export ${REGISTRY_HOST:=localhost} | ||
|
||
x=0 | ||
for f in /ssl/ca.{key,cert}; do | ||
[[ -f $f ]] && x=$((x + 1)) || break | ||
done | ||
case "$x" in | ||
0) | ||
generate_cert -cert=/ssl/ca.cert -key=/ssl/ca.key | ||
;; | ||
1) | ||
echo "Only one of /ssl/ca.key and /ssl/ca.cert was found. Make sure both are either present or absent." && exit 1 | ||
;; | ||
esac | ||
|
||
x=0 | ||
for f in /ssl/registry.{key,crt}; do | ||
[[ -f $f ]] && x=$((x + 1)) || break | ||
done | ||
case "$x" in | ||
0) | ||
generate_cert -cert=/ssl/ca.cert -key=/ssl/ca.key && generate_cert -host="$REGISTRY_HOST" -ca=/ssl/ca.cert -ca-key=/ssl/ca.key -cert=/ssl/registry.crt -key=/ssl/registry.key | ||
;; | ||
1) | ||
echo "Only one of /ssl/registry.key and /ssl/registry.crt was found. Make sure both are either present or absent." && exit 1 | ||
;; | ||
esac | ||
|
||
# --ssl-version 3 == ssl.PROTOCOL_TLSv1 | ||
[[ -d /ssl ]] && export ${GUNICORN_OPTS:="['--certfile','/ssl/registry.crt','--keyfile','/ssl/registry.key','--ca-certs','/ssl/ca.cert','--ssl-version',3]"} | ||
|
||
exec "$@" |