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
688973fa
Commit
688973fa
authored
Mar 21, 2017
by
David Kerr
Browse files
Merge remote-tracking branch 'upstream/master' into ssh-deploy
parents
070a1416
7ebecf38
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
688973fa
...
...
@@ -309,6 +309,7 @@ You don't have to do anything manually!
1.
Gandi LiveDNS API
1.
Knot DNS API
1.
DigitalOcean API (native)
1.
ClouDNS.net API
**More APIs coming soon...**
...
...
acme.sh
View file @
688973fa
...
...
@@ -1131,8 +1131,12 @@ _ss() {
elif
netstat
-help
2>&1 |
grep
--
'-P protocol'
>
/dev/null
;
then
#for solaris
netstat
-an
-P
tcp |
grep
"
\.
$_port
"
|
grep
"LISTEN"
else
elif
netstat
-help
2>&1 |
grep
"
\-
p"
>
/dev/null
;
then
#for full linux
netstat
-ntpl
|
grep
":
$_port
"
else
#for busybox (embedded linux; no pid support)
netstat
-ntl
2>/dev/null |
grep
":
$_port
"
fi
fi
return
0
...
...
@@ -3477,7 +3481,10 @@ issue() {
if
[
!
"
$usingApache
"
]
;
then
if
webroot_owner
=
$(
_stat
"
$_currentRoot
"
)
;
then
_debug
"Changing owner/group of .well-known to
$webroot_owner
"
chown
-R
"
$webroot_owner
"
"
$_currentRoot
/.well-known"
if
!
_exec
"chown -R
\"
$webroot_owner
\"
\"
$_currentRoot
/.well-known
\"
"
;
then
_debug
"
$(
cat
"
$_EXEC_TEMP_ERR
"
)
"
_exec_err
>
/dev/null 2>&1
fi
else
_debug
"not chaning owner/group of webroot"
fi
...
...
dnsapi/README.md
View file @
688973fa
...
...
@@ -407,6 +407,20 @@ Ok, let's issue a cert now:
acme.sh --issue --dns dns_dgon -d example.com -d www.example.com
```
## 21. Use ClouDNS.net API
You need to set the HTTP API user ID and password credentials. See: https://www.cloudns.net/wiki/article/42/
```
export CLOUDNS_AUTH_ID=XXXXX
export CLOUDNS_AUTH_PASSWORD="YYYYYYYYY"
```
Ok, let's issue a cert now:
```
acme.sh --issue --dns dns_cloudns -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_cloudns.sh
0 → 100755
View file @
688973fa
#!/usr/bin/env sh
# Author: Boyan Peychev <boyan at cloudns dot net>
# Repository: https://github.com/ClouDNS/acme.sh/
#CLOUDNS_AUTH_ID=XXXXX
#CLOUDNS_AUTH_PASSWORD="YYYYYYYYY"
CLOUDNS_API
=
"https://api.cloudns.net"
######## Public functions #####################
#Usage: dns_cloudns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_cloudns_add
()
{
_info
"Using cloudns"
if
!
_dns_cloudns_init_check
;
then
return
1
fi
zone
=
"
$(
_dns_cloudns_get_zone_name
"
$1
"
)
"
if
[
-z
"
$zone
"
]
;
then
_err
"Missing DNS zone at ClouDNS. Please log into your control panel and create the required DNS zone for the initial setup."
return
1
fi
host
=
"
$(
echo
"
$1
"
|
sed
"s/
\.
$zone
\$
//"
)
"
record
=
$2
record_id
=
$(
_dns_cloudns_get_record_id
"
$zone
"
"
$host
"
)
_debug zone
"
$zone
"
_debug host
"
$host
"
_debug record
"
$record
"
_debug record_id
"
$record_id
"
if
[
-z
"
$record_id
"
]
;
then
_info
"Adding the TXT record for
$1
"
_dns_cloudns_http_api_call
"dns/add-record.json"
"domain-name=
$zone
&record-type=TXT&host=
$host
&record=
$record
&ttl=60"
if
!
_contains
"
$response
"
"
\"
status
\"
:
\"
Success
\"
"
;
then
_err
"Record cannot be added."
return
1
fi
_info
"Added."
else
_info
"Updating the TXT record for
$1
"
_dns_cloudns_http_api_call
"dns/mod-record.json"
"domain-name=
$zone
&record-id=
$record_id
&record-type=TXT&host=
$host
&record=
$record
&ttl=60"
if
!
_contains
"
$response
"
"
\"
status
\"
:
\"
Success
\"
"
;
then
_err
"The TXT record for
$1
cannot be updated."
return
1
fi
_info
"Updated."
fi
return
0
}
#Usage: dns_cloudns_rm _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_cloudns_rm
()
{
_info
"Using cloudns"
if
!
_dns_cloudns_init_check
;
then
return
1
fi
if
[
-z
"
$zone
"
]
;
then
zone
=
"
$(
_dns_cloudns_get_zone_name
"
$1
"
)
"
if
[
-z
"
$zone
"
]
;
then
_err
"Missing DNS zone at ClouDNS. Please log into your control panel and create the required DNS zone for the initial setup."
return
1
fi
fi
host
=
"
$(
echo
"
$1
"
|
sed
"s/
\.
$zone
\$
//"
)
"
record
=
$2
record_id
=
$(
_dns_cloudns_get_record_id
"
$zone
"
"
$host
"
)
_debug zone
"
$zone
"
_debug host
"
$host
"
_debug record
"
$record
"
_debug record_id
"
$record_id
"
if
[
!
-z
"
$record_id
"
]
;
then
_info
"Deleting the TXT record for
$1
"
_dns_cloudns_http_api_call
"dns/delete-record.json"
"domain-name=
$zone
&record-id=
$record_id
"
if
!
_contains
"
$response
"
"
\"
status
\"
:
\"
Success
\"
"
;
then
_err
"The TXT record for
$1
cannot be deleted."
return
1
fi
_info
"Deleted."
fi
return
0
}
#################### Private functions below ##################################
_dns_cloudns_init_check
()
{
if
[
!
-z
"
$CLOUDNS_INIT_CHECK_COMPLETED
"
]
;
then
return
0
fi
if
[
-z
"
$CLOUDNS_AUTH_ID
"
]
;
then
_err
"CLOUDNS_AUTH_ID is not configured"
return
1
fi
if
[
-z
"
$CLOUDNS_AUTH_PASSWORD
"
]
;
then
_err
"CLOUDNS_AUTH_PASSWORD is not configured"
return
1
fi
_dns_cloudns_http_api_call
"dns/login.json"
""
if
!
_contains
"
$response
"
"
\"
status
\"
:
\"
Success
\"
"
;
then
_err
"Invalid CLOUDNS_AUTH_ID or CLOUDNS_AUTH_PASSWORD. Please check your login credentials."
return
1
fi
CLOUDNS_INIT_CHECK_COMPLETED
=
1
return
0
}
_dns_cloudns_get_zone_name
()
{
i
=
2
while
true
;
do
zoneForCheck
=
$(
printf
"%s"
"
$1
"
|
cut
-d
.
-f
$i
-100
)
if
[
-z
"
$zoneForCheck
"
]
;
then
return
1
fi
_debug zoneForCheck
"
$zoneForCheck
"
_dns_cloudns_http_api_call
"dns/get-zone-info.json"
"domain-name=
$zoneForCheck
"
if
!
_contains
"
$response
"
"
\"
status
\"
:
\"
Failed
\"
"
;
then
echo
"
$zoneForCheck
"
return
0
fi
i
=
$(
_math
"
$i
"
+ 1
)
done
return
1
}
_dns_cloudns_get_record_id
()
{
_dns_cloudns_http_api_call
"dns/records.json"
"domain-name=
$1
&host=
$2
&type=TXT"
if
_contains
"
$response
"
"
\"
id
\"
:"
;
then
echo
"
$response
"
|
cut
-d
'"'
-f
2
return
0
fi
return
1
}
_dns_cloudns_http_api_call
()
{
method
=
$1
_debug CLOUDNS_AUTH_ID
"
$CLOUDNS_AUTH_ID
"
_debug CLOUDNS_AUTH_PASSWORD
"
$CLOUDNS_AUTH_PASSWORD
"
if
[
-z
"
$2
"
]
;
then
data
=
"auth-id=
$CLOUDNS_AUTH_ID
&auth-password=
$CLOUDNS_AUTH_PASSWORD
"
else
data
=
"auth-id=
$CLOUDNS_AUTH_ID
&auth-password=
$CLOUDNS_AUTH_PASSWORD
&
$2
"
fi
response
=
"
$(
_get
"
$CLOUDNS_API
/
$method
?
$data
"
)
"
_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