Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
71cb6d2b
Unverified
Commit
71cb6d2b
authored
Nov 28, 2018
by
neil
Committed by
GitHub
Nov 28, 2018
Browse files
Merge pull request #1759 from hosting-de/feature/hosting.de-plugin
added hosting.de DNS Plugin
parents
50278674
ee258f14
Changes
3
Show whitespace changes
Inline
Side-by-side
README.md
View file @
71cb6d2b
...
...
@@ -328,6 +328,7 @@ You don't have to do anything manually!
1.
GratisDNS.dk (https://gratisdns.dk)
1.
Namecheap API (https://www.namecheap.com/)
1.
MyDNS.JP API (https://www.mydns.jp/)
1.
hosting.de (https://www.hosting.de)
And:
...
...
dnsapi/README.md
View file @
71cb6d2b
...
...
@@ -1030,6 +1030,30 @@ acme.sh --issue --dns dns_mydnsjp -d example.com -d www.example.com
```
The
`MYDNSJP_MasterID`
and
`MYDNSJP_Password`
will be saved in
`~/.acme.sh/account.conf`
and will be reused when needed.
## 55. Use hosting.de API
Create an API key in your hosting.de account here: https://secure.hosting.de
The key needs the following rights:
-
DNS_ZONES_EDIT
-
DNS_ZONES_LIST
Set your API Key and endpoint:
```
export HOSTINGDE_APIKEY='xxx'
export HOSTINGDE_ENDPOINT='https://secure.hosting.de'
```
The plugin can also be used for the http.net API. http.net customers have to set endpoint to https://partner.http.net.
Ok, let's issue a cert now:
```
acme.sh --issue --dns dns_hostingde -d example.com -d *.example.com
```
The hosting.de API key and endpoint will be saved in
`~/.acme.sh/account.conf`
and will be reused when needed.
# Use custom API
If your API is not supported yet, you can write your own DNS API.
...
...
dnsapi/dns_hostingde.sh
0 → 100644
View file @
71cb6d2b
#!/usr/bin/env sh
# hosting.de API
# Values to export:
# export HOSTINGDE_ENDPOINT='https://secure.hosting.de'
# export HOSTINGDE_APIKEY='xxxxx'
######## Public functions #####################
dns_hostingde_add
()
{
fulldomain
=
"
${
1
}
"
txtvalue
=
"
${
2
}
"
_debug
"Calling: _hostingde_addRecord() '
${
fulldomain
}
' '
${
txtvalue
}
'"
_hostingde_apiKey
&&
_hostingde_getZoneConfig
&&
_hostingde_addRecord
}
dns_hostingde_rm
()
{
fulldomain
=
"
${
1
}
"
txtvalue
=
"
${
2
}
"
_debug
"Calling: _hostingde_removeRecord() '
${
fulldomain
}
' '
${
txtvalue
}
'"
_hostingde_apiKey
&&
_hostingde_getZoneConfig
&&
_hostingde_removeRecord
}
#################### own Private functions below ##################################
_hostingde_apiKey
()
{
HOSTINGDE_APIKEY
=
"
${
HOSTINGDE_APIKEY
:-
$(
_readaccountconf_mutable HOSTINGDE_APIKEY
)
}
"
if
[
-z
"
$HOSTINGDE_APIKEY
"
]
||
[
-z
"
$HOSTINGDE_ENDPOINT
"
]
;
then
HOSTINGDE_APIKEY
=
""
HOSTINGDE_ENDPOINT
=
""
_err
"You haven't specified hosting.de API key or endpoint yet."
_err
"Please create your key and try again."
return
1
fi
_saveaccountconf_mutable HOSTINGDE_APIKEY
"
$HOSTINGDE_APIKEY
"
_saveaccountconf_mutable HOSTINGDE_ENDPOINT
"
$HOSTINGDE_ENDPOINT
"
}
_hostingde_getZoneConfig
()
{
_info
"Getting ZoneConfig"
curZone
=
"
${
fulldomain
#*.
}
"
returnCode
=
1
while
_contains
"
${
curZone
}
"
"
\\
."
;
do
curData
=
"{
\"
filter
\"
:{
\"
field
\"
:
\"
zoneName
\"
,
\"
value
\"
:
\"
${
curZone
}
\"
},
\"
limit
\"
:1,
\"
authToken
\"
:
\"
${
HOSTINGDE_APIKEY
}
\"
}"
curResult
=
"
$(
_post
"
${
curData
}
"
"
${
HOSTINGDE_ENDPOINT
}
/api/dns/v1/json/zoneConfigsFind"
)
"
_debug
"Calling zoneConfigsFind: '
${
curData
}
' '
${
HOSTINGDE_ENDPOINT
}
/api/dns/v1/json/zoneConfigsFind'"
_debug
"Result of zoneConfigsFind: '
$curResult
'"
if
_contains
"
${
curResult
}
"
'"status": "error"'
;
then
if
_contains
"
${
curResult
}
"
'"code": 10109'
;
then
_err
"The API-Key is invalid or could not be found"
else
_err
"UNKNOWN API ERROR"
fi
returnCode
=
1
break
fi
if
_contains
"
${
curResult
}
"
'"totalEntries": 1'
;
then
_info
"Retrieved zone data."
_debug
"Zone data: '
${
curResult
}
'"
# read ZoneConfigId for later update
zoneConfigId
=
$(
echo
"
${
curResult
}
"
| _egrep_o
'"id":.*'
|
cut
-d
':'
-f
2 |
cut
-d
'"'
-f
2
)
_debug
"zoneConfigId '
${
zoneConfigId
}
'"
returnCode
=
0
break
fi
curZone
=
"
${
curZone
#*.
}
"
done
if
[
$returnCode
-ne
0
]
;
then
_info
"ZoneEnd reached, Zone
${
curZone
}
not found in hosting.de API"
fi
return
$returnCode
}
_hostingde_addRecord
()
{
_info
"Adding record to zone"
curData
=
"{
\"
authToken
\"
:
\"
${
HOSTINGDE_APIKEY
}
\"
,
\"
zoneConfig
\"
:{
\"
id
\"
:
\"
${
zoneConfigId
}
\"
},
\"
recordsToAdd
\"
:[{
\"
name
\"
:
\"
${
fulldomain
}
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
:
\"\\\"
${
txtvalue
}
\\\"\"
,
\"
ttl
\"
:3600}]}"
curResult
=
"
$(
_post
"
${
curData
}
"
"
${
HOSTINGDE_ENDPOINT
}
/api/dns/v1/json/zoneUpdate"
)
"
_debug
"Calling zoneUpdate: '
${
curData
}
' '
${
HOSTINGDE_ENDPOINT
}
/api/dns/v1/json/zoneUpdate'"
_debug
"Result of zoneUpdate: '
$curResult
'"
if
_contains
"
${
curResult
}
"
'"status": "error"'
;
then
if
_contains
"
${
curResult
}
"
'"code": 10109'
;
then
_err
"The API-Key is invalid or could not be found"
else
_err
"UNKNOWN API ERROR"
fi
return
1
fi
return
0
}
_hostingde_removeRecord
()
{
_info
"Removing record from zone"
curData
=
"{
\"
authToken
\"
:
\"
${
HOSTINGDE_APIKEY
}
\"
,
\"
zoneConfig
\"
:{
\"
id
\"
:
\"
${
zoneConfigId
}
\"
},
\"
recordsToDelete
\"
:[{
\"
name
\"
:
\"
${
fulldomain
}
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
:
\"\\\"
${
txtvalue
}
\\\"\"
}]}"
curResult
=
"
$(
_post
"
${
curData
}
"
"
${
HOSTINGDE_ENDPOINT
}
/api/dns/v1/json/zoneUpdate"
)
"
_debug
"Calling zoneUpdate: '
${
curData
}
' '
${
HOSTINGDE_ENDPOINT
}
/api/dns/v1/json/zoneUpdate'"
_debug
"Result of zoneUpdate: '
$curResult
'"
if
_contains
"
${
curResult
}
"
'"status": "error"'
;
then
if
_contains
"
${
curResult
}
"
'"code": 10109'
;
then
_err
"The API-Key is invalid or could not be found"
else
_err
"UNKNOWN API ERROR"
fi
return
1
fi
return
0
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment