3 ## Acmeproxy DNS provider to be used with acmeproxy (http://github.com/mdbraber/acmeproxy)
4 ## API integration by Maarten den Braber
6 ## Report any bugs via https://github.com/mdbraber/acme.sh
13 _debug
"Calling: _acmeproxy_request() '${fulldomain}' '${txtvalue}' '${action}'"
14 _acmeproxy_request
"$fulldomain" "$txtvalue" "$action"
22 _debug
"Calling: _acmeproxy_request() '${fulldomain}' '${txtvalue}' '${action}'"
23 _acmeproxy_request
"$fulldomain" "$txtvalue" "$action"
26 _acmeproxy_request
() {
28 ## Nothing to see here, just some housekeeping
33 _info
"Using acmeproxy"
34 _debug fulldomain
"$fulldomain"
35 _debug txtvalue
"$txtvalue"
37 ACMEPROXY_ENDPOINT
="${ACMEPROXY_ENDPOINT:-$(_readaccountconf_mutable ACMEPROXY_ENDPOINT)}"
38 ACMEPROXY_USERNAME
="${ACMEPROXY_USERNAME:-$(_readaccountconf_mutable ACMEPROXY_USERNAME)}"
39 ACMEPROXY_PASSWORD
="${ACMEPROXY_PASSWORD:-$(_readaccountconf_mutable ACMEPROXY_PASSWORD)}"
41 ## Check for the endpoint
42 if [ -z "$ACMEPROXY_ENDPOINT" ]; then
44 _err
"You didn't specify the endpoint"
45 _err
"Please set them via 'export ACMEPROXY_ENDPOINT=https://ip:port' and try again."
49 ## Save the credentials to the account file
50 _saveaccountconf_mutable ACMEPROXY_ENDPOINT
"$ACMEPROXY_ENDPOINT"
51 _saveaccountconf_mutable ACMEPROXY_USERNAME
"$ACMEPROXY_USERNAME"
52 _saveaccountconf_mutable ACMEPROXY_PASSWORD
"$ACMEPROXY_PASSWORD"
54 if [ -z "$ACMEPROXY_USERNAME" ] ||
[ -z "$ACMEPROXY_PASSWORD" ]; then
55 _info
"ACMEPROXY_USERNAME and/or ACMEPROXY_PASSWORD not set - using without client authentication! Make sure you're using server authentication (e.g. IP-based)"
56 export _H1
="Accept: application/json"
57 export _H2
="Content-Type: application/json"
59 ## Base64 encode the credentials
60 credentials
=$
(printf "%b" "$ACMEPROXY_USERNAME:$ACMEPROXY_PASSWORD" | _base64
)
62 ## Construct the HTTP Authorization header
63 export _H1
="Authorization: Basic $credentials"
64 export _H2
="Accept: application/json"
65 export _H3
="Content-Type: application/json"
68 ## Add the challenge record to the acmeproxy grid member
69 response
="$(_post "{\"fqdn
\": \"$fulldomain.
\", \"value
\": \"$txtvalue\"}" "$ACMEPROXY_ENDPOINT/$action" "" "POST
")"
71 ## Let's see if we get something intelligible back from the unit
72 if echo "$response" |
grep "\"$txtvalue\"" >/dev
/null
; then
73 _info
"Successfully updated the txt record"
76 _err
"Error encountered during record addition"
83 #################### Private functions below ##################################