Skip to content

Commit f7ee39b

Browse files
committed
fix: cert renewal, add ip cert support
1 parent 0a3ac7c commit f7ee39b

5 files changed

Lines changed: 34 additions & 7 deletions

File tree

acme.sh/cert_utils.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ is_ok_domain_zerossl() {
1010
if [[ $domain == *.$tld ]]; then
1111
return 1 # Domain is restricted
1212
fi
13+
1314
done
1415
return 0 # Domain is not restricted
1516
}
17+
isipv4() {
18+
[[ $1 =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] || return 1
19+
IFS='.' read -r a b c d <<< "$1"
20+
for o in $a $b $c $d; do
21+
(( o >= 0 && o <= 255 )) || return 1
22+
done
23+
return 0
24+
}
25+
26+
isipv6() {
27+
[[ $1 =~ ^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$ ]]
28+
}
1629
function get_cert() {
1730
cd /opt/hiddify-manager/acme.sh/
1831
source ./lib/acme.sh.env
@@ -25,6 +38,7 @@ function get_cert() {
2538
if [ ${#DOMAIN} -le 64 ]; then
2639
mkdir -p /opt/hiddify-manager/acme.sh/www/.well-known/acme-challenge
2740
echo "location /.well-known/acme-challenge {root /opt/hiddify-manager/acme.sh/www/;}" >/opt/hiddify-manager/nginx/parts/acme.conf
41+
chown -R nginx /opt/hiddify-manager/acme.sh/www/
2842
# systemctl reload --now hiddify-nginx
2943

3044
DOMAIN_IP=$(dig +short -t a $DOMAIN.)
@@ -39,11 +53,18 @@ function get_cert() {
3953
# if [ "$SERVER_IPv6" != "" ]; then
4054
# flags="--listen-v6"
4155
# fi
42-
43-
acme.sh --issue -w /opt/hiddify-manager/acme.sh/www/ -d $DOMAIN --log $(pwd)/../log/system/acme.log --server letsencrypt --pre-hook "systemctl restart hiddify-nginx"
44-
if is_ok_domain_zerossl "$DOMAIN"; then
45-
acme.sh --issue -w /opt/hiddify-manager/acme.sh/www/ -d $DOMAIN --log $(pwd)/../log/system/acme.log --pre-hook "systemctl restart hiddify-nginx"
56+
alias acmecmd=acme.sh --issue -w /opt/hiddify-manager/acme.sh/www/ --log $(pwd)/../log/system/acme.log --pre-hook "systemctl restart hiddify-nginx"
57+
if isipv4 "$DOMAIN"; then
58+
acmecmd -d $DOMAIN --server letsencrypt --certificate-profile shortlived --days 6
59+
elif isipv6 "$DOMAIN"; then
60+
acmecmd -d [$DOMAIN] --server letsencrypt --certificate-profile shortlived --days 6
61+
else
62+
acmecmd -d $DOMAIN --server letsencrypt
63+
if is_ok_domain_zerossl "$DOMAIN"; then
64+
acmecmd -d $DOMAIN
65+
fi
4666
fi
67+
4768

4869
cp $ssl_cert_path/$DOMAIN.crt $ssl_cert_path/$DOMAIN.crt.bk
4970
cp $ssl_cert_path/$DOMAIN.crt.key $ssl_cert_path/$DOMAIN.crt.key.bk

acme.sh/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cd $(dirname -- "$0")
12
source ../common/utils.sh
23
source ./cert_utils.sh
34

common/daily_actions.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ cd $( dirname -- "$0"; )
55

66

77
# systemctl restart systemd-journald
8-
# sysctl -w vm.drop_caches=3
8+
# sysctl -w vm.drop_caches=3
9+
10+
11+
12+
bash /opt/hiddify-manager/acme.sh/run.sh

common/install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ bash google-bbr.sh > /dev/null
7575

7676

7777
echo "@reboot root /opt/hiddify-manager/install.sh --no-gui --no-log >> /opt/hiddify-manager/log/system/reboot.log 2>&1" >/etc/cron.d/hiddify_reinstall_on_reboot
78-
echo "@daily root /opt/hiddify-manager/common/daily_actions.sh >> /opt/hiddify-manager/log/system/daily_actions.log 2>&1" >/etc/cron.d/hiddify_daily_memory_release
78+
mv /etc/cron.d/hiddify_daily_memory_release /etc/cron.d/hiddify_daily
79+
echo "@daily root /opt/hiddify-manager/common/daily_actions.sh >> /opt/hiddify-manager/log/system/daily_actions.log 2>&1" >/etc/cron.d/hiddify_daily
7980
service cron reload
8081

8182
if [ "${MODE}" != "docker" ];then

hiddify-panel/src

Submodule src updated from 3dc2383 to 9976c2a

0 commit comments

Comments
 (0)