3 ACME
=/usr
/lib
/acme
/client
/acme.sh
5 # webroot option deprecated, use the exported value directly in the next major version
6 WEBROOT
=${webroot:-$CHALLENGE_DIR}
7 NOTIFY
=/usr
/lib
/acme
/notify
9 # shellcheck source=net/acme/files/functions.sh
10 .
/usr
/lib
/acme
/functions.sh
13 export CURL_CA_BUNDLE
=/etc
/ssl
/certs
/ca-certificates.crt
24 if [ ! -e "$CERT_DIR/$main_domain.crt" ]; then
25 ln -s "$domain_dir/$main_domain.cer" "$CERT_DIR/$main_domain.crt"
27 if [ ! -e "$CERT_DIR/$main_domain.key" ]; then
28 ln -s "$domain_dir/$main_domain.key" "$CERT_DIR/$main_domain.key"
30 if [ ! -e "$CERT_DIR/$main_domain.fullchain.crt" ]; then
31 ln -s "$domain_dir/fullchain.cer" "$CERT_DIR/$main_domain.fullchain.crt"
33 if [ ! -e "$CERT_DIR/$main_domain.chain.crt" ]; then
34 ln -s "$domain_dir/ca.cer" "$CERT_DIR/$main_domain.chain.crt"
41 [ "$debug" = 1 ] && set -- "$@" --debug
45 domain_dir
="$state_dir/${main_domain}_ecc"
49 domain_dir
="$state_dir/$main_domain"
53 log info
"Running ACME for $main_domain"
55 if [ -e "$domain_dir" ]; then
56 if [ "$staging" = 0 ] && grep -q "acme-staging" "$domain_dir/$main_domain.conf"; then
57 mv "$domain_dir" "$domain_dir.staging"
58 log info
"Certificates are previously issued from a staging server, but staging option is diabled, moved to $domain_dir.staging."
61 set -- "$@" --renew --home "$state_dir" -d "$main_domain"
63 trap '$NOTIFY renew-failed;exit 1' INT
70 link_certs
"$domain_dir" "$main_domain"
75 # renew skipped, ignore.
89 set -- "$@" --keylength "$keylength" --accountemail "$account_email"
91 if [ "$acme_server" ]; then
92 set -- "$@" --server "$acme_server"
93 # default to letsencrypt because the upstream default may change
94 elif [ "$staging" = 1 ]; then
95 set -- "$@" --server letsencrypt_test
97 set -- "$@" --server letsencrypt
101 set -- "$@" --days "$days"
105 set -- "$@" --dns "$dns"
106 if [ "$dalias" ]; then
107 set -- "$@" --domain-alias "$dalias"
108 if [ "$calias" ]; then
109 log err
"Both domain and challenge aliases are defined. Ignoring the challenge alias."
111 elif [ "$calias" ]; then
112 set -- "$@" --challenge-alias "$calias"
114 if [ "$dns_wait" ]; then
115 set -- "$@" --dnssleep "$dns_wait"
117 elif [ "$standalone" = 1 ]; then
118 set -- "$@" --standalone --listen-v6
121 set -- "$@" --webroot "$WEBROOT"
124 set -- "$@" --issue --home "$state_dir"
127 trap '$NOTIFY issue-failed;exit 1' INT
129 --pre-hook "$NOTIFY prepare" \
130 --renew-hook "$NOTIFY renewed"
136 link_certs
"$domain_dir" "$main_domain"
140 if [ "$staging_moved" = 1 ]; then
141 mv "$domain_dir.staging" "$domain_dir"
142 log err
"Staging certificate restored"
143 elif [ -d "$domain_dir" ]; then
144 failed_dir
="$domain_dir.failed-$(date +%s)"
145 mv "$domain_dir" "$failed_dir"
146 log err
"State moved to $failed_dir"