Skip to content

Commit 051aadf

Browse files
committed
[Fix] Cleanup temporary files when adding/renewing letsencrypt SSL cert
1 parent dcc5eb1 commit 051aadf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bin/v-add-letsencrypt-domain

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,15 @@ nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n')
360360
status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ')
361361
certificate=$(echo "$answer"|grep 'certificate":' |cut -f4 -d '"')
362362
if [[ "$status" -ne 200 ]]; then
363+
[ -d "$ssl_dir" ] && rm -rf "$ssl_dir"
363364
check_result $E_CONNECT "Let's Encrypt finalize bad status $status"
364365
fi
365366

366367
# Downloading signed certificate / STEP 7
367368
answer=$(query_le_v2 "$certificate" "" "$nonce" "$ssl_dir/$domain.pem")
368369
status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ')
369370
if [[ "$status" -ne 200 ]]; then
371+
[ -d "$ssl_dir" ] && rm -rf "$ssl_dir"
370372
check_result $E_NOTEXIST "Let's Encrypt downloading signed cert failed status:$status"
371373
fi
372374

@@ -408,6 +410,7 @@ else
408410
fi
409411

410412
if [ "$?" -ne '0' ]; then
413+
[ -d "$ssl_dir" ] && rm -rf "$ssl_dir"
411414
touch $HESTIA/data/queue/letsencrypt.pipe
412415
sed -i "/ $domain /d" $HESTIA/data/queue/letsencrypt.pipe
413416
send_notice 'LETSENCRYPT' "$domain certificate installation failed"
@@ -440,6 +443,9 @@ if [ ! -z "$well_known" ]; then
440443
rm -fr $well_known
441444
fi
442445

446+
# Remove temporary SSL folder
447+
[ -d "$ssl_dir" ] && rm -rf "$ssl_dir"
448+
443449
#----------------------------------------------------------#
444450
# Hestia #
445451
#----------------------------------------------------------#

0 commit comments

Comments
 (0)