Skip to content

Commit 2f88f79

Browse files
authored
Merge pull request #212 from ravenpride/master
Added support for choosing a certain key size via environment variable 'LETSENCRYPT_KEYSIZE'.
2 parents a70edeb + 2cb951d commit 2f88f79

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ Set the following environment variables to enable Let's Encrypt support for a co
115115

116116
The `LETSENCRYPT_HOST` variable most likely needs to be the same as the `VIRTUAL_HOST` variable and must be publicly reachable domains. Specify multiple hosts with a comma delimiter.
117117

118+
The following environment variables are optional and parameterize the way the Let's Encrypt client works.
119+
120+
- `LETSENCRYPT_KEYSIZE`
121+
122+
The `LETSENCRYPT_KEYSIZE` variable determines the size of the requested key (in bit, defaults to 4096).
123+
118124
##### multi-domain ([SAN](https://www.digicert.com/subject-alternative-name.htm)) certificates
119125
If you want to create multi-domain ([SAN](https://www.digicert.com/subject-alternative-name.htm)) certificates add the base domain as the first domain of the `LETSENCRYPT_HOST` environment variable.
120126

app/letsencrypt_service

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
55
seconds_to_wait=3600
66
ACME_CA_URI="${ACME_CA_URI:-https://acme-v01.api.letsencrypt.org/directory}"
77
ACME_TOS_HASH="${ACME_TOS_HASH:-6373439b9f29d67a5cd4d18cbc7f264809342dbf21cb2ba2fc7588df987a6221}"
8+
DEFAULT_KEY_SIZE=4096
89

910
source /app/functions.sh
1011

@@ -54,6 +55,12 @@ update_certs() {
5455
hosts_array=$host_varname[@]
5556
email_varname="LETSENCRYPT_${cid}_EMAIL"
5657

58+
keysize_varname="LETSENCRYPT_${cid}_KEYSIZE"
59+
cert_keysize="${!keysize_varname}"
60+
if [[ "$cert_keysize" == "<no value>" ]]; then
61+
cert_keysize=$DEFAULT_KEY_SIZE
62+
fi
63+
5764
test_certificate_varname="LETSENCRYPT_${cid}_TEST"
5865
create_test_certificate=false
5966
if [[ $(lc "${!test_certificate_varname:-}") == true ]]; then
@@ -106,6 +113,7 @@ update_certs() {
106113
-f account_key.json -f key.pem -f chain.pem -f fullchain.pem -f cert.pem \
107114
--tos_sha256 $ACME_TOS_HASH \
108115
$params_d_str \
116+
--cert_key_size=$cert_keysize \
109117
--email "${!email_varname}" \
110118
--server=$acme_ca_uri \
111119
--default_root /usr/share/nginx/html/

app/letsencrypt_service_data.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LETSENCRYPT_CONTAINERS=({{ range $hosts, $containers := groupBy $ "Env.LETSENCRY
77
{{ range $container := $containers }}{{ $cid := printf "%.12s" $container.ID }}
88
LETSENCRYPT_{{ $cid }}_HOST=( {{ range $host := split $hosts "," }}'{{ $host }}' {{ end }})
99
LETSENCRYPT_{{ $cid }}_EMAIL="{{ $container.Env.LETSENCRYPT_EMAIL }}"
10+
LETSENCRYPT_{{ $cid }}_KEYSIZE="{{ $container.Env.LETSENCRYPT_KEYSIZE }}"
1011
LETSENCRYPT_{{ $cid }}_TEST="{{ $container.Env.LETSENCRYPT_TEST }}"
1112
{{ end }}
1213

0 commit comments

Comments
 (0)