Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for wildcard domains #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:latest
FROM certbot/certbot:latest

RUN apk add --update \
certbot curl && \
curl && \
rm -rf /var/cache/apk/*

VOLUME /etc/letsencrypt
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
docker-letsencrypt-gandi
========================

This container generates [LetsEncrypt](https://www.letsencrypt.org) certificates for subdomains at [Gandi](https://www.gandi.net) using the DNS-01 challange type and Gandi's new LiveDNS API. It can also send a SIGHUP signal to a [Nginx container](https://store.docker.com/images/nginx) which tells it to reload its certificates.
This container generates [LetsEncrypt](https://www.letsencrypt.org) certificates for subdomains at [Gandi](https://www.gandi.net) using the DNS-01 challenge type and Gandi's new LiveDNS API. It can also send a SIGHUP signal to a [Nginx container](https://store.docker.com/images/nginx) which tells it to reload its certificates.

This image is based on Alpine and uses [Certbot](https://certbot.eff.org/) to communicate with Letsencrypt.

Expand Down
8 changes: 7 additions & 1 deletion bin/authenticate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ api='https://dns.api.gandi.net/api/v5'
domain=$(echo "$CERTBOT_DOMAIN" | sed -r 's/.+\.(.+\..+)/\1/')
subdomain=$(echo "$CERTBOT_DOMAIN" | sed -r 's/(.+)\..+\..+/\1/')

if [ $subdomain == $domain ]; then
record_name="_acme-challenge"
else
record_name="_acme-challenge.$subdomain"
fi

curl -s -X POST \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $GANDI_API_KEY" \
-d "{\"rrset_name\": \"_acme-challenge.$subdomain\",
-d "{\"rrset_name\": \"$record_name\",
\"rrset_type\": \"TXT\",
\"rrset_ttl\": 300,
\"rrset_values\": [\"$CERTBOT_VALIDATION\"]}" \
Expand Down
8 changes: 7 additions & 1 deletion bin/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ api='https://dns.api.gandi.net/api/v5'
domain=$(echo "$CERTBOT_DOMAIN" | sed -r 's/.+\.(.+\..+)/\1/')
subdomain=$(echo "$CERTBOT_DOMAIN" | sed -r 's/(.+)\..+\..+/\1/')

if [ $subdomain == $domain ]; then
record_name="_acme-challenge"
else
record_name="_acme-challenge.$subdomain"
fi

curl -s -X DELETE \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $GANDI_API_KEY" \
"$api/domains/$domain/records/_acme-challenge.$subdomain/TXT" >&2
"$api/domains/$domain/records/$record_name/TXT" >&2
3 changes: 2 additions & 1 deletion bin/update-certs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

. /etc/update-certs/config
[[ -f /etc/update-certs/config ]] && . /etc/update-certs/config

while true; do
certbot certonly --manual \
Expand All @@ -15,6 +15,7 @@ while true; do
--post-hook reload-nginx.sh \
--email "$EMAIL" \
-d "$DOMAINS" \
--server https://acme-v02.api.letsencrypt.org/directory
"$@"

sleep 5d
Expand Down