-
Notifications
You must be signed in to change notification settings - Fork 14
generate certs if REGISTRY_TLS_VERIFY #31
Changes from 12 commits
119a91a
ddab20d
32b9bb4
c92dfe3
7b2e645
d9966eb
6dfe3eb
ffa4032
bdf500b
2b0b153
cbabe98
dc6ed4a
891f941
cc7a66b
806ee20
018e262
4b3b9b6
81c260b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
docker-registry-core==2.0.2 | ||
docker-registry-core==2.0.3 | ||
gcs-oauth2-boto-plugin==1.8 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
USAGE="docker run -e GCS_BUCKET=<YOUR_GCS_BUCKET_NAME> \ | ||
[-e GCP_ACCOUNT='<YOUR_EMAIL>' ] \ | ||
|
@@ -53,5 +54,39 @@ else | |
fi | ||
fi | ||
|
||
export GCS_BUCKET BOTO_PATH | ||
exec docker-registry $* | ||
if [ -n "${REGISTRY_TLS_VERIFY}" ] && [ -z "${GUNICORN_OPTS}" ]; then | ||
: ${REGISTRY_ADDR:="localhost:5000"} | ||
: ${BOOT2DOCKER_HOST:="boot2docker.local"} | ||
: ${BOOT2DOCKER_IP:="192.168.59.103"} | ||
cat <<EOF > /ssl/ssl.conf | ||
[req] | ||
distinguished_name = req_distinguished_name | ||
[req_distinguished_name] | ||
[v3_ca] | ||
basicConstraints = critical, CA:true, pathlen:0 | ||
keyUsage = critical, keyCertSign | ||
subjectAltName = @alt_names | ||
[v3_req] | ||
basicConstraints = critical, CA:false | ||
keyUsage = critical, digitalSignature | ||
extendedKeyUsage = critical, serverAuth | ||
nsCertType = server | ||
subjectAltName = @alt_names | ||
[alt_names] | ||
DNS.1 = localhost | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @proppy this is hardcoded isnt it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, because when we generate cert we really only care about localhost/boot2docker. If you want to support arbitrary hostname you should bring your own cert for now. See also #33 for later |
||
DNS.2 = ${BOOT2DOCKER_HOST} | ||
IP.1 = 127.0.0.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
IP.2 = ${BOOT2DOCKER_IP} | ||
EOF | ||
echo 01 > /ssl/ca.srl | ||
openssl req -subj "/CN=Local CA" -config /ssl/ssl.conf -extensions v3_ca -new -x509 -days 365 -newkey rsa:2048 -nodes -keyout /ssl/ca.key -out /ssl/ca.crt && chmod 600 /ssl/ca.key | ||
openssl req -subj "/CN=Local Docker registry" -config /ssl/ssl.conf -reqexts v3_req -new -newkey rsa:2048 -nodes -keyout /ssl/registry.key -out /ssl/registry.csr && chmod 600 /ssl/registry.key | ||
openssl x509 -req -extfile /ssl/ssl.conf -extensions v3_req -days 365 -in /ssl/registry.csr -CA /ssl/ca.crt -CAkey /ssl/ca.key -out /ssl/registry.cert | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chmod 600 both of the .key files There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
mkdir -p /certs.d/${REGISTRY_ADDR} | ||
cp /ssl/ca.crt /certs.d/${REGISTRY_ADDR}/ | ||
SSL_VERSION=$(python -c 'import ssl; print ssl.PROTOCOL_TLSv1') | ||
: ${GUNICORN_OPTS:="['--certfile','/ssl/registry.cert','--keyfile','/ssl/registry.key','--ca-certs','/ssl/ca.crt','--ssl-version','$SSL_VERSION','--log-level','debug']"} | ||
fi | ||
|
||
export GCS_BUCKET BOTO_PATH GUNICORN_OPTS | ||
exec "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@proppy don't you wanna make sure users are using tlsv1 ? (would need
'--ssl-version', 3
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.