Skip to content

Commit b7fe7a4

Browse files
authored
Merge pull request #6333 from EfficientIP-Labs/dns_efficientip
Implement DNS API for Efficientip SOLIDserver
2 parents 3b2c2b1 + 75ee17a commit b7fe7a4

File tree

2 files changed

+140
-1
lines changed

2 files changed

+140
-1
lines changed

acme.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ _digest() {
10311031

10321032
outputhex="$2"
10331033

1034-
if [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ] || [ "$alg" = "md5" ]; then
1034+
if [ "$alg" = "sha3-256" ] || [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ] || [ "$alg" = "md5" ]; then
10351035
if [ "$outputhex" ]; then
10361036
${ACME_OPENSSL_BIN:-openssl} dgst -"$alg" -hex | cut -d = -f 2 | tr -d ' '
10371037
else

dnsapi/dns_efficientip.sh

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/usr/bin/env sh
2+
# shellcheck disable=SC2034
3+
dns_efficientip_info='efficientip.com
4+
Site: https://efficientip.com/
5+
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_efficientip
6+
Options:
7+
EfficientIP_Creds HTTP Basic Authentication credentials. E.g. "username:password"
8+
EfficientIP_Server EfficientIP SOLIDserver Management IP address or FQDN.
9+
EfficientIP_DNS_Name Name of the DNS smart or server hosting the zone. Optional.
10+
EfficientIP_View Name of the DNS view hosting the zone. Optional.
11+
OptionsAlt:
12+
EfficientIP_Token_Key Alternative API token key, prefered over basic authentication.
13+
EfficientIP_Token_Secret Alternative API token secret, required when using a token key.
14+
EfficientIP_Server EfficientIP SOLIDserver Management IP address or FQDN.
15+
EfficientIP_DNS_Name Name of the DNS smart or server hosting the zone. Optional.
16+
EfficientIP_View Name of the DNS view hosting the zone. Optional.
17+
Issues: github.com/acmesh-official/acme.sh/issues/6325
18+
Author: EfficientIP-Labs <[email protected]>
19+
'
20+
21+
dns_efficientip_add() {
22+
fulldomain=$1
23+
txtvalue=$2
24+
25+
_info "Using EfficientIP API"
26+
_debug fulldomain "$fulldomain"
27+
_debug txtvalue "$txtvalue"
28+
29+
if { [ -z "${EfficientIP_Creds}" ] && { [ -z "${EfficientIP_Token_Key}" ] || [ -z "${EfficientIP_Token_Secret}" ]; }; } || [ -z "${EfficientIP_Server}" ]; then
30+
EfficientIP_Creds=""
31+
EfficientIP_Token_Key=""
32+
EfficientIP_Token_Secret=""
33+
EfficientIP_Server=""
34+
_err "You didn't specify any EfficientIP credentials or token or server (EfficientIP_Creds; EfficientIP_Token_Key; EfficientIP_Token_Secret; EfficientIP_Server)."
35+
_err "Please set them via EXPORT EfficientIP_Creds=username:password or EXPORT EfficientIP_server=ip/hostname"
36+
_err "or if you want to use Token instead EXPORT EfficientIP_Token_Key=yourkey"
37+
_err "and EXPORT EfficientIP_Token_Secret=yoursecret"
38+
_err "then try again."
39+
return 1
40+
fi
41+
42+
if [ -z "${EfficientIP_DNS_Name}" ]; then
43+
EfficientIP_DNS_Name=""
44+
fi
45+
46+
EfficientIP_DNSNameEncoded=$(printf "%b" "${EfficientIP_DNS_Name}" | _url_encode)
47+
48+
if [ -z "${EfficientIP_View}" ]; then
49+
EfficientIP_View=""
50+
fi
51+
52+
EfficientIP_ViewEncoded=$(printf "%b" "${EfficientIP_View}" | _url_encode)
53+
54+
_saveaccountconf EfficientIP_Creds "${EfficientIP_Creds}"
55+
_saveaccountconf EfficientIP_Token_Key "${EfficientIP_Token_Key}"
56+
_saveaccountconf EfficientIP_Token_Secret "${EfficientIP_Token_Secret}"
57+
_saveaccountconf EfficientIP_Server "${EfficientIP_Server}"
58+
_saveaccountconf EfficientIP_DNS_Name "${EfficientIP_DNS_Name}"
59+
_saveaccountconf EfficientIP_View "${EfficientIP_View}"
60+
61+
export _H1="Accept-Language:en-US"
62+
baseurlnObject="https://${EfficientIP_Server}/rest/dns_rr_add?rr_type=TXT&rr_ttl=300&rr_name=${fulldomain}&rr_value1=${txtvalue}"
63+
64+
if [ "${EfficientIP_DNSNameEncoded}" != "" ]; then
65+
baseurlnObject="${baseurlnObject}&dns_name=${EfficientIP_DNSNameEncoded}"
66+
fi
67+
68+
if [ "${EfficientIP_ViewEncoded}" != "" ]; then
69+
baseurlnObject="${baseurlnObject}&dnsview_name=${EfficientIP_ViewEncoded}"
70+
fi
71+
72+
if [ -z "${EfficientIP_Token_Secret}" ] || [ -z "${EfficientIP_Token_Key}" ]; then
73+
EfficientIP_CredsEncoded=$(printf "%b" "${EfficientIP_Creds}" | _base64)
74+
export _H2="Authorization: Basic ${EfficientIP_CredsEncoded}"
75+
else
76+
TS=$(date +%s)
77+
Sig=$(printf "%b\n$TS\nPOST\n$baseurlnObject" "${EfficientIP_Token_Secret}" | _digest sha3-256 hex)
78+
EfficientIP_CredsEncoded=$(printf "%b:%b" "${EfficientIP_Token_Key}" "$Sig")
79+
export _H2="Authorization: SDS ${EfficientIP_CredsEncoded}"
80+
export _H3="X-SDS-TS: ${TS}"
81+
fi
82+
83+
result="$(_post "" "${baseurlnObject}" "" "POST")"
84+
85+
if [ "$(echo "${result}" | _egrep_o "ret_oid")" ]; then
86+
_info "DNS record successfully created"
87+
return 0
88+
else
89+
_err "Error creating DNS record"
90+
_err "${result}"
91+
return 1
92+
fi
93+
}
94+
95+
dns_efficientip_rm() {
96+
fulldomain=$1
97+
txtvalue=$2
98+
99+
_info "Using EfficientIP API"
100+
_debug fulldomain "${fulldomain}"
101+
_debug txtvalue "${txtvalue}"
102+
103+
EfficientIP_ViewEncoded=$(printf "%b" "${EfficientIP_View}" | _url_encode)
104+
EfficientIP_DNSNameEncoded=$(printf "%b" "${EfficientIP_DNS_Name}" | _url_encode)
105+
EfficientIP_CredsEncoded=$(printf "%b" "${EfficientIP_Creds}" | _base64)
106+
107+
export _H1="Accept-Language:en-US"
108+
109+
baseurlnObject="https://${EfficientIP_Server}/rest/dns_rr_delete?rr_type=TXT&rr_name=$fulldomain&rr_value1=$txtvalue"
110+
if [ "${EfficientIP_DNSNameEncoded}" != "" ]; then
111+
baseurlnObject="${baseurlnObject}&dns_name=${EfficientIP_DNSNameEncoded}"
112+
fi
113+
114+
if [ "${EfficientIP_ViewEncoded}" != "" ]; then
115+
baseurlnObject="${baseurlnObject}&dnsview_name=${EfficientIP_ViewEncoded}"
116+
fi
117+
118+
if [ -z "$EfficientIP_Token_Secret" ] || [ -z "$EfficientIP_Token_Key" ]; then
119+
EfficientIP_CredsEncoded=$(printf "%b" "${EfficientIP_Creds}" | _base64)
120+
export _H2="Authorization: Basic $EfficientIP_CredsEncoded"
121+
else
122+
TS=$(date +%s)
123+
Sig=$(printf "%b\n$TS\nDELETE\n${baseurlnObject}" "${EfficientIP_Token_Secret}" | _digest sha3-256 hex)
124+
EfficientIP_CredsEncoded=$(printf "%b:%b" "${EfficientIP_Token_Key}" "$Sig")
125+
export _H2="Authorization: SDS ${EfficientIP_CredsEncoded}"
126+
export _H3="X-SDS-TS: $TS"
127+
fi
128+
129+
result="$(_post "" "${baseurlnObject}" "" "DELETE")"
130+
131+
if [ "$(echo "${result}" | _egrep_o "ret_oid")" ]; then
132+
_info "DNS Record successfully deleted"
133+
return 0
134+
else
135+
_err "Error deleting DNS record"
136+
_err "${result}"
137+
return 1
138+
fi
139+
}

0 commit comments

Comments
 (0)