mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-05 00:36:09 +03:00
fix(ssl): preserve independent IP certificates and enable Alpine renewal
This commit is contained in:
@@ -254,6 +254,9 @@ if ! live_is new || [[ ! -f "$state/current/reload-pending" ]]; then fail 'reloa
|
||||
[[ "$(stat -Lc %a "$cert_dir/privkey.pem")" == 600 ]] || fail 'private key permissions changed'
|
||||
[[ "$(stat -Lc %a "$cert_dir/fullchain.pem")" == 644 ]] || fail 'certificate permissions changed'
|
||||
[[ ! -e "$legacy/$ipv4" && ! -e "$legacy/${ipv4}_ecc" ]] || fail 'old cron can still target live paths'
|
||||
mkdir "$legacy/$ipv4"
|
||||
cp "$TEMP/old.pem" "$legacy/$ipv4/fullchain.cer"
|
||||
printf "Le_Alt='no'\n" > "$legacy/$ipv4/$ipv4.conf"
|
||||
[[ "$(grep -cx 'arg=--listen-v4' "$ACME_LOG")" == 1 && "$(grep -cx 'arg=--listen-v6' "$ACME_LOG")" == 1 ]] || fail 'dual-stack flags absent'
|
||||
[[ "$(grep -cx "arg=$ipv6" "$ACME_LOG")" == 1 ]] || fail 'IPv6 SAN duplicated or missing'
|
||||
grep -Fq '/unrelated-cron' "$CRON_FILE" || fail 'crontab lost an unrelated entry'
|
||||
@@ -365,6 +368,7 @@ if wait "$failed_pid"; then fail 'injected promotion failure reported success';
|
||||
wait "$waiting_pid" || { cat "$TEMP/waiting-promotion"; fail 'second promotion failed'; }
|
||||
unset -f mv
|
||||
live_is later || fail 'rollback overwrote a newer promotion'
|
||||
cmp "$TEMP/old.pem" "$legacy/$ipv4/fullchain.cer" || fail 'an unrelated certificate using the same IP was retired'
|
||||
printf 'PASS: a failed promotion cannot roll back another operation on the same paths\n'
|
||||
|
||||
before=$(wc -l < "$ACME_LOG")
|
||||
|
||||
@@ -48,7 +48,14 @@ printf 'PASS: installer consent, explicit configuration, no unattended prompts,
|
||||
|
||||
setup_ip_certificate() { return 1; }
|
||||
systemctl() { :; }
|
||||
rc-service() { :; }
|
||||
rc-service() {
|
||||
case "$*" in
|
||||
'x-ui stop') : ;;
|
||||
'crond status') [[ "${CROND_RUNNING:-0}" == 1 ]] ;;
|
||||
'dcron start') printf 'rc-service %s\n' "$*" >> "$TEMP/cron" ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
NONINTERACTIVE=1
|
||||
export XUI_SSL_IPV6='2001:4860::1'
|
||||
for release in ubuntu alpine; do
|
||||
@@ -58,3 +65,11 @@ for release in ubuntu alpine; do
|
||||
[[ "$SSL_HOST" == 198.51.100.8 ]] || fail 'the installer lost its access host after a failed certificate'
|
||||
done
|
||||
printf 'PASS: a failed IP certificate is reported and the installer carries on on systemd/OpenRC\n'
|
||||
|
||||
rc-update() { printf 'rc-update %s\n' "$*" >> "$TEMP/cron"; }
|
||||
ip_ssl_enable_openrc_cron ubuntu
|
||||
CROND_RUNNING=1 ip_ssl_enable_openrc_cron alpine
|
||||
[[ ! -e "$TEMP/cron" ]] || fail 'an existing cron service was disturbed'
|
||||
ip_ssl_enable_openrc_cron alpine
|
||||
[[ "$(cat "$TEMP/cron")" == $'rc-update add dcron default\nrc-service dcron start' ]] || fail 'Alpine cron was not enabled and started'
|
||||
printf 'PASS: IP setup keeps an existing daemon and enables Alpine cron when needed\n'
|
||||
|
||||
Reference in New Issue
Block a user