Skip to content

Commit 02c54ef

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Allow specification of a key type"
2 parents 03f4951 + f1248fe commit 02c54ef

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

docker/letsencrypt/letsencrypt-lego/letsencrypt-certificates.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function obtain_or_renew_certificate {
2323
local eab="${8}"
2424
local hmac="${9}"
2525
local key_id="${10}"
26+
local letsencrypt_key_type="${11:-}"
2627

2728
certificate_domain_opts=$(echo ${certificate_fqdns} | sed -r -e 's/^/,/g' -e 's/,/--domains=/g' -e 's/--/ --/g')
2829
certificate_fqdn=$(echo ${certificate_fqdns} | awk -F ',' '{print $1}')
@@ -69,6 +70,7 @@ function obtain_or_renew_certificate {
6970

7071
log_info "[${certificate_fqdn} - cron] Obtaining certificate for domains ${certificate_fqdns}."
7172
mapfile -t cmd_output < <(/opt/lego --email="${mail}" \
73+
$( [ -n "${letsencrypt_key_type}" ] && echo "--key-type ${letsencrypt_key_type}" ) \
7274
${certificate_domain_opts} \
7375
--server "${acme_url}" \
7476
--path "/etc/letsencrypt/lego/${certificate_type}/" \
@@ -118,7 +120,7 @@ KEY_ID="NONE"
118120
LOG_FILE="/var/log/kolla/letsencrypt/lesencrypt-lego.log"
119121

120122

121-
VALID_ARGS=$(getopt -o ief:p:d:m:a:v:h: --long internal,external,fqdns:,port:,days:,mail:,acme:,vips:,haproxies-ssh:,eab,kid:,hmac: -- "$@")
123+
VALID_ARGS=$(getopt -o ief:p:d:m:a:v:h:k: --long internal,external,fqdns:,port:,days:,mail:,acme:,vips:,haproxies-ssh:,eab,kid:,hmac:,key-type: -- "$@")
122124
if [[ $? -ne 0 ]]; then
123125
exit 1;
124126
fi
@@ -176,6 +178,10 @@ while [ : ]; do
176178
KEY_ID="${2}"
177179
shift 2
178180
;;
181+
-k | --key-type)
182+
LETSENCRYPT_KEY_TYPE="${2}"
183+
shift 2
184+
;;
179185
--) shift;
180186
break
181187
;;
@@ -203,12 +209,12 @@ if [ "${INTERNAL_SET}" = "true" ] || [ "${EXTERNAL_SET}" = "true" ]; then
203209
log_info "[${FQDN} - cron] This Letsencrypt-lego host is active..."
204210
if [ "${LETSENCRYPT_INTERNAL_FQDNS}" != "" ]; then
205211
log_info "[${FQDN} - cron] Processing domains ${LETSENCRYPT_INTERNAL_FQDNS}"
206-
obtain_or_renew_certificate ${LETSENCRYPT_INTERNAL_FQDNS} internal ${PORT} ${DAYS} ${ACME} ${MAIL} ${LETSENCRYPT_SSH_PORT} ${EXTERNAL_ACCOUNT_BINDING} ${HMAC} ${KEY_ID}
212+
obtain_or_renew_certificate ${LETSENCRYPT_INTERNAL_FQDNS} internal ${PORT} ${DAYS} ${ACME} ${MAIL} ${LETSENCRYPT_SSH_PORT} ${EXTERNAL_ACCOUNT_BINDING} ${HMAC} ${KEY_ID} ${LETSENCRYPT_KEY_TYPE}
207213
fi
208214

209215
if [ "${LETSENCRYPT_EXTERNAL_FQDNS}" != "" ]; then
210216
log_info "[${FQDN} - cron] Processing domains ${LETSENCRYPT_EXTERNAL_FQDNS}"
211-
obtain_or_renew_certificate ${LETSENCRYPT_EXTERNAL_FQDNS} external ${PORT} ${DAYS} ${ACME} ${MAIL} ${LETSENCRYPT_SSH_PORT} ${EXTERNAL_ACCOUNT_BINDING} ${HMAC} ${KEY_ID}
217+
obtain_or_renew_certificate ${LETSENCRYPT_EXTERNAL_FQDNS} external ${PORT} ${DAYS} ${ACME} ${MAIL} ${LETSENCRYPT_SSH_PORT} ${EXTERNAL_ACCOUNT_BINDING} ${HMAC} ${KEY_ID} ${LETSENCRYPT_KEY_TYPE}
212218
fi
213219
else
214220
log_info "[${FQDN} - cron] This Letsencrypt-lego host is passive, nothing to do..."

0 commit comments

Comments
 (0)