Browse Source

Initial commit.

pull/1/head
Chris Smith 6 years ago
commit
1ff74ea5c0
6 changed files with 1414 additions and 0 deletions
  1. 16
    0
      Dockerfile
  2. 23
    0
      LICENCE
  3. 68
    0
      README.md
  4. 13
    0
      config
  5. 1271
    0
      dehydrated
  6. 23
    0
      run.sh

+ 16
- 0
Dockerfile View File

@@ -0,0 +1,16 @@
1
+FROM ubuntu:xenial 
2
+MAINTAINER Chris Smith <dle@chameth.com> 
3
+
4
+RUN apt-get update \
5
+ && apt-get install -y \
6
+      curl \
7
+      inotify-tools
8
+
9
+COPY dehydrated run.sh config /
10
+RUN chmod +x /run.sh /dehydrated
11
+
12
+VOLUME ["/letsencrypt"]
13
+
14
+ENTRYPOINT ["/bin/bash"]
15
+CMD ["/run.sh"]
16
+

+ 23
- 0
LICENCE View File

@@ -0,0 +1,23 @@
1
+The MIT License (MIT)
2
+
3
+boulder copyright (c) 2015-2017 Lukas Schauer
4
+all other content copyright (c) 2016-2017 Chris Smith
5
+
6
+
7
+Permission is hereby granted, free of charge, to any person obtaining a copy
8
+of this software and associated documentation files (the "Software"), to deal
9
+in the Software without restriction, including without limitation the rights
10
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+copies of the Software, and to permit persons to whom the Software is
12
+furnished to do so, subject to the following conditions:
13
+
14
+The above copyright notice and this permission notice shall be included in all
15
+copies or substantial portions of the Software.
16
+
17
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+SOFTWARE.

+ 68
- 0
README.md View File

@@ -0,0 +1,68 @@
1
+# Let's Encrypt HTTP Service
2
+
3
+This container uses [dehydrated](https://github.com/lukas2511/dehydrated)
4
+to automatically obtain SSL certs from [Let's Encrypt](https://letsencrypt.org/).
5
+
6
+You will need a webserver that will serve the challenge responses when
7
+queried by Let's Encrypt, such as my
8
+[service-nginx](https://github.com/csmith/docker-service-nginx) container.
9
+
10
+Multiple domains, as well as SANs, are supported. Certificates will be
11
+renewed automatically, and obtained automatically as soon as new domains
12
+are added.
13
+
14
+## Usage
15
+
16
+### Accepting Let's Encrypt's terms
17
+
18
+In order to issue certificates with Let's Encrypt, you must agree to the
19
+Let's Encrypt terms of service. You can do this by running the command
20
+`/dehydrated --register --accept-terms` from within the container.
21
+
22
+For ease of automation, you can define the `ACCEPT_CA_TERMS` env var
23
+(with any non-empty value) to automatically accept the terms. Be warned
24
+that doing so will automatically accept any future changes to the terms
25
+of service.
26
+
27
+### Defining domains
28
+
29
+The container defines one volume at `/letsencrypt`, and expects there to be
30
+a list of domains in `/letsencrypt/domains.txt`. Certificates are output to
31
+`/letsencrypt/certs/{domain}`.
32
+
33
+domains.txt should contain one line per certificate. If you want alternate
34
+names on the cert, these should be listed after the primary domain. e.g.
35
+
36
+```
37
+example.com www.example.com
38
+admin.example.com
39
+```
40
+
41
+This will request two certificates: one for example.com with a SAN of
42
+www.example.com, and a separate one for admin.example.com.
43
+
44
+The container uses inotify to monitor the domains.txt file for changes,
45
+so you can update it while the container is running and changes will be
46
+automatically applied.
47
+
48
+### Well-known files 
49
+
50
+To verify that you own the domain, a webserver must be listening for
51
+requests and serve a unique file under the `/.well-known/acme-challenge`
52
+directory. The responses for these files are written by this container
53
+to `/letsencrypt/well-known`. 
54
+
55
+### Other configuration
56
+
57
+For testing purposes, you can set the `STAGING` environment variable to
58
+a non-empty value. This will use the Let's Encrypt staging server, which
59
+has much more relaxed limits.
60
+
61
+You should pass in a contact e-mail address by setting the `EMAIL` env var.
62
+This is passed on to Let's Encrypt, and may be used for important service
63
+announcements.
64
+
65
+By default this container uses Eliptic Curve keys. You can override this
66
+behaviour by setting the `ALGORITHM` environment variable. Dehydrated
67
+supports the following algorithms: `rsa`, `prime256v1` and `secp384r1`.
68
+

+ 13
- 0
config View File

@@ -0,0 +1,13 @@
1
+#!/usr/bin/env bash
2
+
3
+WELLKNOWN=/letsencrypt/well-known
4
+BASEDIR=/letsencrypt
5
+CONTACT_EMAIL=$EMAIL
6
+KEY_ALGO=${ALGORITHM:-secp384r1}
7
+
8
+if [ -z ${STAGING+-} ]; then
9
+  CA="https://acme-v01.api.letsencrypt.org/directory"
10
+else
11
+  CA="https://acme-staging.api.letsencrypt.org/directory"
12
+fi
13
+

+ 1271
- 0
dehydrated
File diff suppressed because it is too large
View File


+ 23
- 0
run.sh View File

@@ -0,0 +1,23 @@
1
+#!/usr/bin/env bash
2
+
3
+interrupt() {
4
+  echo
5
+  echo "Caught ^C, exiting."
6
+  exit 1
7
+}
8
+
9
+trap interrupt SIGINT
10
+
11
+if [ -n "${ACCEPT_CA_TERMS:-}" ]; then
12
+  DEHYDRATED_CMD="/dehydrated --accept-terms"
13
+else
14
+  DEHYDRATED_CMD="/dehydrated"
15
+fi
16
+
17
+while true; do
18
+  $DEHYDRATED_CMD --cron --challenge http-01
19
+  $DEHYDRATED_CMD --cleanup
20
+  inotifywait --timeout 86400 /letsencrypt/domains.txt
21
+  sleep 60
22
+done
23
+

Loading…
Cancel
Save