Skip to content

Commit 679a965

Browse files
hentihenti-smith-oxajaydrogers
authored
Add support for "--expand" and "--cert-name" (#21)
* Add support for expand When adding mulitple hosts on a single cloudflare domain, the additional domains will be added as "Subject Alternative Name" and the certificate will need to be updated. Since the default setting in certbot is to ask, this fails. This change adds support for CERTBOT_EXPAND, which when set to true, will add the `--expand` option on the certbot run. * Update docs and Dockerfile Removed entry for CERTBOT_EXPAND in Dockerfile as it's optional. Updated docs to include CERTBOT_EXPAND * Enhance README and Dockerfile; deprecate CERTBOT_EXPAND Updated README to clarify usage of CERTBOT_DOMAINS and introduced CERTBOT_CERT_NAME for explicit certificate management. Marked CERTBOT_EXPAND as deprecated, recommending the use of CERTBOT_CERT_NAME instead. Adjusted Dockerfile to include new environment variable and set default values accordingly. --------- Co-authored-by: Henti Smith <henti.smith@oxa.tech> Co-authored-by: Jay Rogers <jaydrogers@users.noreply.serversideup.net> Co-authored-by: Jay Rogers <3174134+jaydrogers@users.noreply.github.com>
1 parent f04bd08 commit 679a965

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ The following environment variables can be used to customize the Certbot contain
5656
5757
| Variable | Description | Default Value |
5858
|------------------------|---------------------------------------------------------------------|---------------|
59-
| `CERTBOT_DOMAINS` | Comma-separated list of domains for which to obtain the certificate | - |
59+
| `CERTBOT_DOMAINS` | Comma-separated list of domains for which to obtain the certificate (example: `example.com,www.example.com`) | - |
60+
| `CERTBOT_CERT_NAME` | Explicit certificate name to update/modify ([See official docs →](https://eff-certbot.readthedocs.io/en/stable/using.html#changing-a-certificate-s-domains)) | - |
61+
| `CERTBOT_EXPAND` | **DEPRECATED**: Expand existing certificate to add domains (use CERTBOT_CERT_NAME instead, [see official docs →](https://eff-certbot.readthedocs.io/en/stable/using.html#re-creating-and-updating-existing-certificates)) | `false` |
6062
| `CERTBOT_EMAIL` | Email address for Let's Encrypt notifications | - |
6163
| `CERTBOT_KEY_TYPE` | Type of private key to generate | `ecdsa` |
6264
| `CERTBOT_SERVER` | The ACME server URL | `https://acme-v02.api.letsencrypt.org/directory` |

src/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ ARG CERTBOT_GID=9999
99

1010
ENV CERTBOT_DOMAINS="" \
1111
CERTBOT_EMAIL="" \
12+
CERTBOT_EXPAND=false \
13+
CERTBOT_CERT_NAME="" \
1214
CERTBOT_KEY_TYPE="ecdsa" \
1315
CERTBOT_SERVER="https://acme-v02.api.letsencrypt.org/directory" \
1416
CLOUDFLARE_API_TOKEN="" \

src/entrypoint.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ run_certbot() {
105105
debug_flag=""
106106
[ "$DEBUG" = "true" ] && debug_flag="-v"
107107

108+
# Build additional certbot flags using positional parameters
109+
set -- # Reset positional parameters
110+
111+
if [ -n "$CERTBOT_CERT_NAME" ]; then
112+
set -- "$@" --cert-name "$CERTBOT_CERT_NAME"
113+
elif [ "$CERTBOT_EXPAND" = "true" ]; then
114+
set -- "$@" --expand
115+
fi
116+
117+
# Run certbot command
108118
$certbot_cmd $debug_flag certonly \
109119
--dns-cloudflare \
110120
--dns-cloudflare-credentials "$CLOUDFLARE_CREDENTIALS_FILE" \
@@ -115,7 +125,8 @@ run_certbot() {
115125
--server "$CERTBOT_SERVER" \
116126
--agree-tos \
117127
--non-interactive \
118-
--strict-permissions
128+
--strict-permissions \
129+
"$@"
119130
exit_code=$?
120131
if [ $exit_code -ne 0 ]; then
121132
echo "Error: certbot command failed with exit code $exit_code"

0 commit comments

Comments
 (0)