Skip to content

Commit a5af334

Browse files
safhomeSAFjaapmarcusScIT-Raphael
authored
fix for hestiacp#2176, hestiacp#2041 - Temporarily disable HTTPS redirection and force SSL when renewing LE certificate (hestiacp#2304)
* fix for hestiacp#2176, hestiacp#2041 * Resolve comments on PR - Replace source conf with the more secure: parse_object_kv_list - $SSL_FORCE, $REDIRECT_CODE and $REDIRECT where allready availble and don't require a lookup - Add a final restart of the webservers when command is complete to make sure the config has been reloaded with the correct settings * Fix shellcheck error * Remove irrelevant spaces. Co-authored-by: SAF <saf@advina.ru> Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com> Co-authored-by: Raphael Schneeberger <rs@scit.ch>
1 parent d13b60a commit a5af334

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

bin/v-update-letsencrypt-ssl

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ for user in $($HESTIA/bin/v-list-sys-users plain); do
6767
aliases=$(echo "$aliases" |egrep -v "^$domain,?$")
6868
aliases=$(echo "$aliases" |sed -e ':a;N;$!ba;s/\n/,/g')
6969

70-
# Source domain.conf
71-
source <(cat $HESTIA/data/users/$user/web.conf | grep "DOMAIN='$domain'")
70+
# Parsing domain
71+
parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
7272

7373
# Split aliases into array
7474
IFS=',' read -r -a ALIASES <<< "$ALIAS"
@@ -88,7 +88,18 @@ for user in $($HESTIA/bin/v-list-sys-users plain); do
8888
if [[ ${f_aliases: -1} = ',' ]] ; then f_aliases=${f_aliases::-1}; fi
8989

9090
# Write the filtered alias list to the default var
91-
aliases=$f_aliases
91+
aliases=$f_aliases
92+
93+
domain_redirect="$REDIRECT"
94+
if [[ -n "$domain_redirect" ]] ; then
95+
domain_redirect_code="$REDIRECT_CODE"
96+
$BIN/v-delete-web-domain-redirect $user $domain
97+
fi
98+
99+
domain_forcessl="$SSL_FORCE"
100+
if [[ "$domain_forcessl" == 'yes' ]] ; then
101+
$BIN/v-delete-web-domain-ssl-force $user $domain
102+
fi
92103

93104
msg=$($BIN/v-add-letsencrypt-domain "$user" "$domain" "$aliases")
94105
if [ $? -ne 0 ]; then
@@ -103,6 +114,13 @@ for user in $($HESTIA/bin/v-list-sys-users plain); do
103114
else
104115
$BIN/v-log-action "$user" "Info" "Web" "Let's Encrypt SSL certificate renewed (Domain: $domain)."
105116
fi
117+
if [[ "$domain_forcessl" == 'yes' ]] ; then
118+
$BIN/v-add-web-domain-ssl-force $user $domain
119+
fi
120+
if [[ -n "$domain_redirect" ]] ; then
121+
$BIN/v-add-web-domain-redirect $user $domain $domain_redirect $domain_redirect_code
122+
fi
123+
106124
fi
107125
done
108126

@@ -147,6 +165,12 @@ for user in $($HESTIA/bin/v-list-sys-users plain); do
147165

148166
done
149167

168+
$HESTIA/bin/v-restart-web yes
169+
if [ -n "$PROXY_SYSTEM" ]; then
170+
$HESTIA/bin/v-restart-proxy yes
171+
fi
172+
173+
150174
#----------------------------------------------------------#
151175
# Hestia #
152176
#----------------------------------------------------------#

0 commit comments

Comments
 (0)