Skip to content

Commit 03dd318

Browse files
authored
Merge pull request #6505 from acmesh-official/dev
sync
2 parents 52e051b + fc3bfda commit 03dd318

38 files changed

+444
-98
lines changed

.github/workflows/wiki-monitor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
with:
1313
repository: ${{ github.repository }}.wiki
1414
path: wiki
15+
fetch-depth: 0
1516

1617
- name: Generate wiki change message
1718
run: |
@@ -58,3 +59,4 @@ jobs:
5859

5960

6061

62+

acme.sh

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,10 @@ _time() {
18111811
# 2022-04-01 08:10:33 to 1648800633
18121812
#or 2022-04-01T08:10:33Z to 1648800633
18131813
_date2time() {
1814+
#Mac/BSD
1815+
if date -u -j -f "%Y-%m-%d %H:%M:%S" "$(echo "$1" | tr -d "Z" | tr "T" ' ')" +"%s" 2>/dev/null; then
1816+
return
1817+
fi
18141818
#Linux
18151819
if date -u -d "$(echo "$1" | tr -d "Z" | tr "T" ' ')" +"%s" 2>/dev/null; then
18161820
return
@@ -1820,10 +1824,6 @@ _date2time() {
18201824
if gdate -u -d "$(echo "$1" | tr -d "Z" | tr "T" ' ')" +"%s" 2>/dev/null; then
18211825
return
18221826
fi
1823-
#Mac/BSD
1824-
if date -u -j -f "%Y-%m-%d %H:%M:%S" "$(echo "$1" | tr -d "Z" | tr "T" ' ')" +"%s" 2>/dev/null; then
1825-
return
1826-
fi
18271827
#Omnios
18281828
if python3 -c "import datetime; print(int(datetime.datetime.strptime(\"$1\", \"%Y-%m-%d %H:%M:%S\").replace(tzinfo=datetime.timezone.utc).timestamp()))" 2>/dev/null; then
18291829
return
@@ -2538,15 +2538,19 @@ _startserver() {
25382538
_NC="socat"
25392539
if [ "$Le_Listen_V6" ]; then
25402540
_NC="$_NC -6"
2541-
else
2541+
SOCAT_OPTIONS=TCP6-LISTEN
2542+
elif [ "$Le_Listen_V4" ]; then
25422543
_NC="$_NC -4"
2544+
SOCAT_OPTIONS=TCP4-LISTEN
2545+
else
2546+
SOCAT_OPTIONS=TCP-LISTEN
25432547
fi
25442548

25452549
if [ "$DEBUG" ] && [ "$DEBUG" -gt "1" ]; then
25462550
_NC="$_NC -d -d -v"
25472551
fi
25482552

2549-
SOCAT_OPTIONS=TCP-LISTEN:$Le_HTTPPort,crlf,reuseaddr,fork
2553+
SOCAT_OPTIONS=$SOCAT_OPTIONS:$Le_HTTPPort,crlf,reuseaddr,fork
25502554

25512555
#Adding bind to local-address
25522556
if [ "$ncaddr" ]; then
@@ -3513,7 +3517,7 @@ _on_before_issue() {
35133517
_debug _chk_alt_domains "$_chk_alt_domains"
35143518
#run pre hook
35153519
if [ "$_chk_pre_hook" ]; then
3516-
_info "Runing pre hook:'$_chk_pre_hook'"
3520+
_info "Running pre hook:'$_chk_pre_hook'"
35173521
if ! (
35183522
export Le_Domain="$_chk_main_domain"
35193523
export Le_Alt="$_chk_alt_domains"
@@ -4502,6 +4506,7 @@ issue() {
45024506

45034507
if ! _on_before_issue "$_web_roots" "$_main_domain" "$_alt_domains" "$_pre_hook" "$_local_addr"; then
45044508
_err "_on_before_issue."
4509+
_on_issue_err "$_post_hook"
45054510
return 1
45064511
fi
45074512

@@ -4761,7 +4766,8 @@ $_authorizations_map"
47614766
_debug keyauthorization "$keyauthorization"
47624767
fi
47634768

4764-
entry="$(echo "$response" | _egrep_o '[^\{]*"type":"'$vtype'"[^\}]*')"
4769+
# Fix for empty error objects in response which mess up the original code, adapted from fix suggested here: https://github.com/acmesh-official/acme.sh/issues/4933#issuecomment-1870499018
4770+
entry="$(echo "$response" | sed s/'"error":{}'/'"error":null'/ | _egrep_o '[^\{]*"type":"'$vtype'"[^\}]*')"
47654771
_debug entry "$entry"
47664772

47674773
if [ -z "$keyauthorization" -a -z "$entry" ]; then
@@ -6350,7 +6356,8 @@ _deactivate() {
63506356
fi
63516357
_debug "Trigger validation."
63526358
vtype="$(_getIdType "$_d_domain")"
6353-
entry="$(echo "$response" | _egrep_o '[^\{]*"type":"'$vtype'"[^\}]*')"
6359+
# Fix for empty error objects in response which mess up the original code, adapted from fix suggested here: https://github.com/acmesh-official/acme.sh/issues/4933#issuecomment-1870499018
6360+
entry="$(echo "$response" | sed s/'"error":{}'/'"error":null'/ | _egrep_o '[^\{]*"type":"'$vtype'"[^\}]*')"
63546361
_debug entry "$entry"
63556362
if [ -z "$entry" ]; then
63566363
_err "$d: Cannot get domain token"

deploy/panos.sh

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,26 @@
77
#
88
# Firewall admin with superuser and IP address is required.
99
#
10-
# REQURED:
10+
# REQUIRED:
1111
# export PANOS_HOST=""
1212
# export PANOS_USER="" #User *MUST* have Commit and Import Permissions in XML API for Admin Role
1313
# export PANOS_PASS=""
1414
#
1515
# OPTIONAL
16-
# export PANOS_TEMPLATE="" #Template Name of panorama managed devices
16+
# export PANOS_TEMPLATE="" # Template Name of panorama managed devices
17+
# export PANOS_TEMPLATE_STACK="" # set a Template Stack if certificate should also be pushed automatically
18+
# export PANOS_VSYS="Shared" # name of the vsys to import the certificate
1719
#
1820
# The script will automatically generate a new API key if
1921
# no key is found, or if a saved key has expired or is invalid.
2022

23+
_COMMIT_WAIT_INTERVAL=30 # query commit status every 30 seconds
24+
_COMMIT_WAIT_ITERATIONS=20 # query commit status 20 times (20*30 = 600 seconds = 10 minutes)
25+
2126
# This function is to parse the XML response from the firewall
2227
parse_response() {
2328
type=$2
29+
_debug "API Response: $1"
2430
if [ "$type" = 'keygen' ]; then
2531
status=$(echo "$1" | sed 's/^.*\(['\'']\)\([a-z]*\)'\''.*/\2/g')
2632
if [ "$status" = "success" ]; then
@@ -30,6 +36,13 @@ parse_response() {
3036
message="PAN-OS Key could not be set."
3137
fi
3238
else
39+
if [ "$type" = 'commit' ]; then
40+
job_id=$(echo "$1" | sed 's/^.*\(<job>\)\(.*\)<\/job>.*/\2/g')
41+
_commit_job_id=$job_id
42+
elif [ "$type" = 'job_status' ]; then
43+
job_status=$(echo "$1" | tr -d '\n' | sed 's/^.*<result>\([^<]*\)<\/result>.*/\1/g')
44+
_commit_job_status=$job_status
45+
fi
3346
status=$(echo "$1" | tr -d '\n' | sed 's/^.*"\([a-z]*\)".*/\1/g')
3447
message=$(echo "$1" | tr -d '\n' | sed 's/.*\(<result>\|<msg>\|<line>\)\([^<]*\).*/\2/g')
3548
_debug "Firewall message: $message"
@@ -44,13 +57,13 @@ parse_response() {
4457
#This function is used to deploy to the firewall
4558
deployer() {
4659
content=""
47-
type=$1 # Types are keytest, keygen, cert, key, commit
60+
type=$1 # Types are keytest, keygen, cert, key, commit, job_status, push
4861
panos_url="https://$_panos_host/api/"
62+
export _H1="Content-Type: application/x-www-form-urlencoded"
4963

5064
#Test API Key by performing a lookup
5165
if [ "$type" = 'keytest' ]; then
5266
_debug "**** Testing saved API Key ****"
53-
_H1="Content-Type: application/x-www-form-urlencoded"
5467
# Get Version Info to test key
5568
content="type=version&key=$_panos_key"
5669
## Exclude all scopes for the empty commit
@@ -61,7 +74,6 @@ deployer() {
6174
# Generate API Key
6275
if [ "$type" = 'keygen' ]; then
6376
_debug "**** Generating new API Key ****"
64-
_H1="Content-Type: application/x-www-form-urlencoded"
6577
content="type=keygen&user=$_panos_user&password=$_panos_pass"
6678
# content="$content${nl}--$delim${nl}Content-Disposition: form-data; type=\"keygen\"; user=\"$_panos_user\"; password=\"$_panos_pass\"${nl}Content-Type: application/octet-stream${nl}${nl}"
6779
fi
@@ -84,6 +96,9 @@ deployer() {
8496
if [ "$_panos_template" ]; then
8597
content="$content${nl}--$delim${nl}Content-Disposition: form-data; name=\"target-tpl\"\r\n\r\n$_panos_template"
8698
fi
99+
if [ "$_panos_vsys" ]; then
100+
content="$content${nl}--$delim${nl}Content-Disposition: form-data; name=\"target-tpl-vsys\"\r\n\r\n$_panos_vsys"
101+
fi
87102
fi
88103
if [ "$type" = 'key' ]; then
89104
panos_url="${panos_url}?type=import"
@@ -96,6 +111,9 @@ deployer() {
96111
if [ "$_panos_template" ]; then
97112
content="$content${nl}--$delim${nl}Content-Disposition: form-data; name=\"target-tpl\"\r\n\r\n$_panos_template"
98113
fi
114+
if [ "$_panos_vsys" ]; then
115+
content="$content${nl}--$delim${nl}Content-Disposition: form-data; name=\"target-tpl-vsys\"\r\n\r\n$_panos_vsys"
116+
fi
99117
fi
100118
#Close multipart
101119
content="$content${nl}--$delim--${nl}${nl}"
@@ -106,7 +124,6 @@ deployer() {
106124
# Commit changes
107125
if [ "$type" = 'commit' ]; then
108126
_debug "**** Committing changes ****"
109-
export _H1="Content-Type: application/x-www-form-urlencoded"
110127
#Check for force commit - will commit ALL uncommited changes to the firewall. Use with caution!
111128
if [ "$FORCE" ]; then
112129
_debug "Force switch detected. Committing ALL changes to the firewall."
@@ -118,6 +135,20 @@ deployer() {
118135
content="type=commit&action=partial&key=$_panos_key&cmd=$cmd"
119136
fi
120137

138+
# Query job status
139+
if [ "$type" = 'job_status' ]; then
140+
echo "**** Querying job $_commit_job_id status ****"
141+
cmd=$(printf "%s" "<show><jobs><id>$_commit_job_id</id></jobs></show>" | _url_encode)
142+
content="type=op&key=$_panos_key&cmd=$cmd"
143+
fi
144+
145+
# Push changes
146+
if [ "$type" = 'push' ]; then
147+
echo "**** Pushing changes ****"
148+
cmd=$(printf "%s" "<commit-all><template-stack><name>$_panos_template_stack</name><admin><member>$_panos_user</member></admin></template-stack></commit-all>" | _url_encode)
149+
content="type=commit&action=all&key=$_panos_key&cmd=$cmd"
150+
fi
151+
121152
response=$(_post "$content" "$panos_url" "" "POST")
122153
parse_response "$response" "$type"
123154
# Saving response to variables
@@ -126,6 +157,8 @@ deployer() {
126157
if [ "$response_status" = "success" ]; then
127158
_debug "Successfully deployed $type"
128159
return 0
160+
elif [ "$_commit_job_status" ]; then
161+
_debug "Commit Job Status = $_commit_job_status"
129162
else
130163
_err "Deploy of type $type failed. Try deploying with --debug to troubleshoot."
131164
_debug "$message"
@@ -191,11 +224,31 @@ panos_deploy() {
191224
_getdeployconf PANOS_TEMPLATE
192225
fi
193226

227+
# PANOS_TEMPLATE_STACK
228+
if [ "$PANOS_TEMPLATE_STACK" ]; then
229+
_debug "Detected ENV variable PANOS_TEMPLATE_STACK. Saving to file."
230+
_savedeployconf PANOS_TEMPLATE_STACK "$PANOS_TEMPLATE_STACK" 1
231+
else
232+
_debug "Attempting to load variable PANOS_TEMPLATE_STACK from file."
233+
_getdeployconf PANOS_TEMPLATE_STACK
234+
fi
235+
236+
# PANOS_TEMPLATE_STACK
237+
if [ "$PANOS_VSYS" ]; then
238+
_debug "Detected ENV variable PANOS_VSYS. Saving to file."
239+
_savedeployconf PANOS_VSYS "$PANOS_VSYS" 1
240+
else
241+
_debug "Attempting to load variable PANOS_VSYS from file."
242+
_getdeployconf PANOS_VSYS
243+
fi
244+
194245
#Store variables
195246
_panos_host=$PANOS_HOST
196247
_panos_user=$PANOS_USER
197248
_panos_pass=$PANOS_PASS
198249
_panos_template=$PANOS_TEMPLATE
250+
_panos_template_stack=$PANOS_TEMPLATE_STACK
251+
_panos_vsys=$PANOS_VSYS
199252

200253
#Test API Key if found. If the key is invalid, the variable _panos_key will be unset.
201254
if [ "$_panos_host" ] && [ "$_panos_key" ]; then
@@ -229,6 +282,20 @@ panos_deploy() {
229282
deployer cert
230283
deployer key
231284
deployer commit
285+
if [ "$_panos_template_stack" ]; then
286+
# try to get job status for 20 times in 30 sec interval
287+
i=0
288+
while [ "$i" -lt $_COMMIT_WAIT_ITERATIONS ]; do
289+
deployer job_status
290+
if [ "$_commit_job_status" = "OK" ]; then
291+
echo "Commit finished!"
292+
break
293+
fi
294+
sleep $_COMMIT_WAIT_INTERVAL
295+
i=$((i + 1))
296+
done
297+
deployer push
298+
fi
232299
fi
233300
fi
234301
}

deploy/proxmoxbs.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ HEREDOC
115115
_info "Push certificates to server"
116116
export HTTPS_INSECURE=1
117117
export _H1="Authorization: PBSAPIToken=${_proxmoxbs_header_api_token}"
118-
_post "$_json_payload" "$_target_url" "" POST "application/json"
118+
response=$(_post "$_json_payload" "$_target_url" "" POST "application/json")
119+
_retval=$?
120+
if [ "${_retval}" -eq 0 ]; then
121+
_debug3 response "$response"
122+
_info "Certificate successfully deployed"
123+
return 0
124+
else
125+
_err "Certificate deployment failed"
126+
_debug "Response" "$response"
127+
return 1
128+
fi
119129

120130
}

deploy/proxmoxve.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ HEREDOC
127127
_info "Push certificates to server"
128128
export HTTPS_INSECURE=1
129129
export _H1="Authorization: PVEAPIToken=${_proxmoxve_header_api_token}"
130-
_post "$_json_payload" "$_target_url" "" POST "application/json"
130+
response=$(_post "$_json_payload" "$_target_url" "" POST "application/json")
131+
_retval=$?
132+
if [ "${_retval}" -eq 0 ]; then
133+
_debug3 response "$response"
134+
_info "Certificate successfully deployed"
135+
return 0
136+
else
137+
_err "Certificate deployment failed"
138+
_debug "Response" "$response"
139+
return 1
140+
fi
131141

132142
}

dnsapi/dns_beget.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Options:
77
BEGET_User API user
88
BEGET_Password API password
99
Issues: github.com/acmesh-official/acme.sh/issues/6200
10-
Author: ARNik [email protected]
10+
Author: ARNik <[email protected]>
1111
'
1212

1313
Beget_Api="https://api.beget.com/api"

dnsapi/dns_bookmyname.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Options:
77
BOOKMYNAME_USERNAME Username
88
BOOKMYNAME_PASSWORD Password
99
Issues: github.com/acmesh-official/acme.sh/issues/3209
10-
Author: Neilpang
10+
Author: @Neilpang
1111
'
1212

1313
######## Public functions #####################

dnsapi/dns_constellix.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ dns_constellix_rm() {
117117
#################### Private functions below ##################################
118118

119119
_get_root() {
120-
domain=$1
120+
domain=$(echo "$1" | _lower_case)
121121
i=2
122122
p=1
123123
_debug "Detecting root zone"
@@ -156,6 +156,9 @@ _constellix_rest() {
156156
data="$3"
157157
_debug "$ep"
158158

159+
# Prevent rate limit
160+
_sleep 2
161+
159162
rdate=$(date +"%s")"000"
160163
hmac=$(printf "%s" "$rdate" | _hmac sha1 "$(printf "%s" "$CONSTELLIX_Secret" | _hex_dump | tr -d ' ')" | _base64)
161164

dnsapi/dns_ddnss.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi#dns_ddnss
66
Options:
77
DDNSS_Token API Token
88
Issues: github.com/acmesh-official/acme.sh/issues/2230
9-
Author: RaidenII, helbgd, mod242
9+
Author: @helbgd, @mod242
1010
'
1111

1212
DDNSS_DNS_API="https://ddnss.de/upd.php"

dnsapi/dns_dnshome.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Options:
77
DNSHOME_Subdomain Subdomain
88
DNSHOME_SubdomainPassword Subdomain Password
99
Issues: github.com/acmesh-official/acme.sh/issues/3819
10-
Author: dnsHome.de https://github.com/dnsHome-de
10+
Author: @dnsHome-de
1111
'
1212

1313
# Usage: add subdomain.ddnsdomain.tld "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"

0 commit comments

Comments
 (0)