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
a0037c93
Commit
a0037c93
authored
Feb 28, 2017
by
neil
Committed by
GitHub
Feb 28, 2017
Browse files
Merge pull request #683 from Neilpang/dev
Dev
parents
59f7a2f6
177b57e1
Changes
4
Show whitespace changes
Inline
Side-by-side
README.md
View file @
a0037c93
...
...
@@ -294,6 +294,7 @@ You don't have to do anything manually!
1.
FreeDNS (https://freedns.afraid.org/)
1.
cyon.ch
1.
Domain-Offensive/Resellerinterface/Domainrobot API
1.
Gandi LiveDNS API
**More APIs coming soon...**
...
...
acme.sh
View file @
a0037c93
...
...
@@ -1485,6 +1485,11 @@ _inithttp() {
fi
fi
#from wget 1.14: do not skip body on 404 error
if [ "$_ACME_WGET" ] && _contains "$($_ACME_WGET --help)" "--content-on-error"; then
_ACME_WGET="$_ACME_WGET --content-on-error "
fi
__HTTP_INITIALIZED=1
}
...
...
@@ -1546,7 +1551,7 @@ _post() {
_ret="$?"
if [ "$_ret" = "8" ]; then
_ret=0
_debug "wget returns 8, the server returns a 'Bad request' respons, lets process the response later."
_debug "wget returns 8, the server returns a 'Bad request' respons
e
, lets process the response later."
fi
if [ "$_ret" != "0" ]; then
_err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $_ret"
...
...
@@ -1609,9 +1614,9 @@ _get() {
$_WGET --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" -O - "$url"
fi
ret=$?
if [ "$
_
ret" = "8" ]; then
_
ret=0
_debug "wget returns 8, the server returns a 'Bad request' respons, lets process the response later."
if [ "$ret" = "8" ]; then
ret=0
_debug "wget returns 8, the server returns a 'Bad request' respons
e
, lets process the response later."
fi
if [ "$ret" != "0" ]; then
_err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $ret"
...
...
dnsapi/README.md
View file @
a0037c93
...
...
@@ -336,6 +336,19 @@ Ok, let's issue a cert now:
acme.sh --issue --dns dns_do -d example.com -d www.example.com
```
## 18. Use Gandi LiveDNS API
You must enable the new Gandi LiveDNS API first and the create your api key, See: http://doc.livedns.gandi.net/
```
export GANDI_LIVEDNS_KEY="fdmlfsdklmfdkmqsdfk"
```
Ok, let's issue a cert now:
```
acme.sh --issue --dns dns_gandi_livedns -d example.com -d www.example.com
```
# Use custom API
If your API is not supported yet, you can write your own DNS API.
...
...
dnsapi/dns_gandi_livedns.sh
0 → 100755
View file @
a0037c93
#!/usr/bin/env sh
# Gandi LiveDNS v5 API
# http://doc.livedns.gandi.net/
# currently under beta
#
# Requires GANDI API KEY set in GANDI_LIVEDNS_KEY set as environment variable
#
#Author: Frédéric Crozat <fcrozat@suse.com>
#Report Bugs here: https://github.com/fcrozat/acme.sh
#
######## Public functions #####################
GANDI_LIVEDNS_API
=
"https://dns.beta.gandi.net/api/v5"
#Usage: dns_gandi_livedns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_gandi_livedns_add
()
{
fulldomain
=
$1
txtvalue
=
$2
if
[
-z
"
$GANDI_LIVEDNS_KEY
"
]
;
then
_err
"No API key specifed for Gandi LiveDNS."
_err
"Create your key and export it as GANDI_LIVEDNS_KEY"
return
1
fi
_saveaccountconf GANDI_LIVEDNS_KEY
"
$GANDI_LIVEDNS_KEY
"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
fi
_debug fulldomain
"
$fulldomain
"
_debug txtvalue
"
$txtvalue
"
_debug domain
"
$_domain
"
_debug sub_domain
"
$_sub_domain
"
_gandi_livedns_rest PUT
"domains/
$_domain
/records/
$_sub_domain
/TXT"
"{
\"
rrset_ttl
\"
: 300,
\"
rrset_values
\"
:[
\"
$txtvalue
\"
]}"
\
&&
_contains
"
$response
"
'{"message": "Zone Record Created"}'
\
&&
_info
"Add
$(
__green
"success"
)
"
}
#Usage: fulldomain txtvalue
#Remove the txt record after validation.
dns_gandi_livedns_rm
()
{
fulldomain
=
$1
txtvalue
=
$2
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
fi
_debug fulldomain
"
$fulldomain
"
_debug domain
"
$_domain
"
_debug sub_domain
"
$_sub_domain
"
_gandi_livedns_rest DELETE
"domains/
$_domain
/records/
$_sub_domain
/TXT"
""
}
#################### Private functions below ##################################
#_acme-challenge.www.domain.com
#returns
# _sub_domain=_acme-challenge.www
# _domain=domain.com
_get_root
()
{
domain
=
$1
i
=
2
p
=
1
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug h
"
$h
"
if
[
-z
"
$h
"
]
;
then
#not valid
return
1
fi
if
!
_gandi_livedns_rest GET
"domains/
$h
"
;
then
return
1
fi
if
_contains
"
$response
"
'"code": 401'
;
then
_err
"
$response
"
return
1
elif
_contains
"
$response
"
'"code": 404'
;
then
_debug
"
$h
not found"
else
_sub_domain
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
1-
$p
)
_domain
=
"
$h
"
return
0
fi
p
=
"
$i
"
i
=
$(
_math
"
$i
"
+ 1
)
done
return
1
}
_gandi_livedns_rest
()
{
m
=
$1
ep
=
"
$2
"
data
=
"
$3
"
_debug
"
$ep
"
export
_H1
=
"Content-Type: application/json"
export
_H2
=
"X-Api-Key:
$GANDI_LIVEDNS_KEY
"
if
[
"
$m
"
=
"GET"
]
;
then
response
=
"
$(
_get
"
$GANDI_LIVEDNS_API
/
$ep
"
)
"
else
_debug data
"
$data
"
response
=
"
$(
_post
"
$data
"
"
$GANDI_LIVEDNS_API
/
$ep
"
""
"
$m
"
)
"
fi
if
[
"
$?
"
!=
"0"
]
;
then
_err
"error
$ep
"
return
1
fi
_debug2 response
"
$response
"
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