Unverified Commit ce38ecb9 authored by Philippe Kueck's avatar Philippe Kueck
Browse files

merge with upstream

parents 13ffa170 1e2d5598
<!--
If it is a bug report:
- make sure you are able to repro it on the latest released version.
You can install the latest version by: `acme.sh --upgrade`
- Search the existing issues.
- Refer to the [WIKI](https://wiki.acme.sh).
- Debug info [Debug](https://github.com/Neilpang/acme.sh/wiki/How-to-debug-acme.sh).
-->
Steps to reproduce
------------------
Debug log
-----------------
```
acme.sh --issue ..... --debug 2
```
language: shell
env:
global:
- SHFMT_URL=https://github.com/mvdan/sh/releases/download/v0.4.0/shfmt_v0.4.0_linux_amd64
addons:
apt:
sources:
- debian-sid # Grab shellcheck from the Debian repo (o_O)
packages:
- shellcheck
script:
- curl -sSL $SHFMT_URL -o ~/shfmt
- chmod +x ~/shfmt
- shellcheck -V
- shellcheck -e SC2021,SC2126,SC2034 **/*.sh && echo "shellcheck OK"
- ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && false)
matrix:
fast_finish: true
# An ACME Shell script: acme.sh # An ACME Shell script: acme.sh [![Build Status](https://travis-ci.org/Neilpang/acme.sh.svg?branch=master)](https://travis-ci.org/Neilpang/acme.sh)
- An ACME protocol client written purely in Shell (Unix shell) language. - An ACME protocol client written purely in Shell (Unix shell) language.
- Fully ACME protocol implementation. - Fully ACME protocol implementation.
- Simple, powerful and very easy to use. You only need 3 minutes to learn. - Simple, powerful and very easy to use. You only need 3 minutes to learn.
...@@ -36,6 +36,7 @@ Wiki: https://github.com/Neilpang/acme.sh/wiki ...@@ -36,6 +36,7 @@ Wiki: https://github.com/Neilpang/acme.sh/wiki
|16|[![](https://cdn.rawgit.com/Neilpang/acmetest/master/status/mageia.svg)](https://github.com/Neilpang/letest#here-are-the-latest-status)|Mageia |16|[![](https://cdn.rawgit.com/Neilpang/acmetest/master/status/mageia.svg)](https://github.com/Neilpang/letest#here-are-the-latest-status)|Mageia
|17|-----| OpenWRT: Tested and working. See [wiki page](https://github.com/Neilpang/acme.sh/wiki/How-to-run-on-OpenWRT) |17|-----| OpenWRT: Tested and working. See [wiki page](https://github.com/Neilpang/acme.sh/wiki/How-to-run-on-OpenWRT)
|18|[![](https://cdn.rawgit.com/Neilpang/acmetest/master/status/solaris.svg)](https://github.com/Neilpang/letest#here-are-the-latest-status)|SunOS/Solaris |18|[![](https://cdn.rawgit.com/Neilpang/acmetest/master/status/solaris.svg)](https://github.com/Neilpang/letest#here-are-the-latest-status)|SunOS/Solaris
|19|[![](https://cdn.rawgit.com/Neilpang/acmetest/master/status/gentoo-stage3-amd64.svg)](https://github.com/Neilpang/letest#here-are-the-latest-status)|Gentoo Linux
For all build statuses, check our [daily build project](https://github.com/Neilpang/acmetest): For all build statuses, check our [daily build project](https://github.com/Neilpang/acmetest):
...@@ -137,15 +138,24 @@ More examples: https://github.com/Neilpang/acme.sh/wiki/How-to-issue-a-cert ...@@ -137,15 +138,24 @@ More examples: https://github.com/Neilpang/acme.sh/wiki/How-to-issue-a-cert
# 3. Install the issued cert to apache/nginx etc. # 3. Install the issued cert to apache/nginx etc.
After you issue a cert, you probably want to install/copy the cert to your nginx/apache or other servers you may be using. After you issue a cert, you probably want to install/copy the cert to your nginx/apache or other servers.
You **MUST** use this command to copy the certs to the target files, **Do NOT** use the certs files in **.acme.sh/** folder, they are for internal use only, the folder structure may change in future.
**nginx** example
```bash ```bash
acme.sh --installcert -d example.com \ acme.sh --installcert -d example.com \
--certpath /path/to/certfile/in/apache/nginx \ --keypath /path/to/keyfile/in/nginx/key.pem \
--keypath /path/to/keyfile/in/apache/nginx \ --fullchainpath path/to/fullchain/nginx/cert.pem \
--capath /path/to/ca/certfile/apache/nginx \ --reloadcmd "service nginx restart"
--fullchainpath path/to/fullchain/certfile/apache/nginx \ ```
--reloadcmd "service apache2|nginx reload"
**apache** example
```bash
acme.sh --installcert -d example.com \
--certpath /path/to/certfile/in/apache/cert.pem \
--keypath /path/to/keyfile/in/apache/key.pem \
--fullchainpath path/to/fullchain/certfile/apache/fullchain.pem \
--reloadcmd "service apache2 restart"
``` ```
Only the domain is required, all the other parameters are optional. Only the domain is required, all the other parameters are optional.
...@@ -244,7 +254,9 @@ You don't have do anything manually! ...@@ -244,7 +254,9 @@ You don't have do anything manually!
7. PowerDNS API 7. PowerDNS API
8. lexicon dns api: https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api 8. lexicon dns api: https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api
(DigitalOcean, DNSimple, DnsMadeEasy, DNSPark, EasyDNS, Namesilo, NS1, PointHQ, Rage4 and Vultr etc.) (DigitalOcean, DNSimple, DnsMadeEasy, DNSPark, EasyDNS, Namesilo, NS1, PointHQ, Rage4 and Vultr etc.)
9. nsupdate 9. LuaDNS.com API
10. DNSMadeEasy.com API
11. nsupdate
##### More APIs are coming soon... ##### More APIs are coming soon...
......
This diff is collapsed.
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#Which will be called by acme.sh to deploy the cert #Which will be called by acme.sh to deploy the cert
#returns 0 means success, otherwise error. #returns 0 means success, otherwise error.
######## Public functions ##################### ######## Public functions #####################
#domain keyfile certfile cafile fullchain #domain keyfile certfile cafile fullchain
...@@ -24,10 +22,7 @@ myapi_deploy() { ...@@ -24,10 +22,7 @@ myapi_deploy() {
_debug _cca "$_cca" _debug _cca "$_cca"
_debug _cfullchain "$_cfullchain" _debug _cfullchain "$_cfullchain"
_err "Not implemented yet" _err "Not implemented yet"
return 1 return 1
} }
...@@ -186,4 +186,41 @@ For more details, please check our sample script: [dns_myapi.sh](dns_myapi.sh) ...@@ -186,4 +186,41 @@ For more details, please check our sample script: [dns_myapi.sh](dns_myapi.sh)
https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api
## Use LuaDNS domain API
Get your API token at https://api.luadns.com/settings
```
export LUA_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
export LUA_Email="xxxx@sss.com"
```
To issue a cert:
```
acme.sh --issue --dns dns_lua --dnssleep 3 -d example.com -d www.example.com
```
The `LUA_Key` and `LUA_Email` will be saved in `~/.acme.sh/account.conf`, and will be reused when needed.
## Use DNSMadeEasy domain API
Get your API credentials at https://cp.dnsmadeeasy.com/account/info
```
export ME_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
export ME_Secret="qdfqsdfkjdskfj"
```
To issue a cert:
```
acme.sh --issue --dns dns_me --dnssleep 3 -d example.com -d www.example.com
```
The `ME_Key` and `ME_Secret` will be saved in `~/.acme.sh/account.conf`, and will be reused when needed.
#!/usr/bin/env sh #!/usr/bin/env sh
# #
#CF_Key="sdfsdfsdfljlbjkljlkjsdfoiwje" #CF_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
# #
#CF_Email="xxxx@sss.com" #CF_Email="xxxx@sss.com"
CF_Api="https://api.cloudflare.com/client/v4" CF_Api="https://api.cloudflare.com/client/v4"
######## Public functions ##################### ######## Public functions #####################
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_cf_add(){ dns_cf_add() {
fulldomain=$1 fulldomain=$1
txtvalue=$2 txtvalue=$2
if [ -z "$CF_Key" ] || [ -z "$CF_Email" ] ; then if [ -z "$CF_Key" ] || [ -z "$CF_Email" ]; then
CF_Key=""
CF_Email=""
_err "You don't specify cloudflare api key and email yet." _err "You don't specify cloudflare api key and email yet."
_err "Please create you key and try again." _err "Please create you key and try again."
return 1 return 1
...@@ -27,7 +27,7 @@ dns_cf_add(){ ...@@ -27,7 +27,7 @@ dns_cf_add(){
_saveaccountconf CF_Email "$CF_Email" _saveaccountconf CF_Email "$CF_Email"
_debug "First detect the root zone" _debug "First detect the root zone"
if ! _get_root $fulldomain ; then if ! _get_root "$fulldomain"; then
_err "invalid domain" _err "invalid domain"
return 1 return 1
fi fi
...@@ -38,17 +38,17 @@ dns_cf_add(){ ...@@ -38,17 +38,17 @@ dns_cf_add(){
_debug "Getting txt records" _debug "Getting txt records"
_cf_rest GET "zones/${_domain_id}/dns_records?type=TXT&name=$fulldomain" _cf_rest GET "zones/${_domain_id}/dns_records?type=TXT&name=$fulldomain"
if ! printf "$response" | grep \"success\":true > /dev/null ; then if ! printf "%s" "$response" | grep \"success\":true >/dev/null; then
_err "Error" _err "Error"
return 1 return 1
fi fi
count=$(printf "%s\n" "$response" | _egrep_o \"count\":[^,]* | cut -d : -f 2) count=$(printf "%s\n" "$response" | _egrep_o "\"count\":[^,]*" | cut -d : -f 2)
_debug count "$count" _debug count "$count"
if [ "$count" = "0" ] ; then if [ "$count" = "0" ]; then
_info "Adding record" _info "Adding record"
if _cf_rest POST "zones/$_domain_id/dns_records" "{\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"ttl\":120}"; then if _cf_rest POST "zones/$_domain_id/dns_records" "{\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"ttl\":120}"; then
if printf -- "%s" "$response" | grep $fulldomain > /dev/null ; then if printf -- "%s" "$response" | grep "$fulldomain" >/dev/null; then
_info "Added, sleeping 10 seconds" _info "Added, sleeping 10 seconds"
sleep 10 sleep 10
#todo: check if the record takes effect #todo: check if the record takes effect
...@@ -61,15 +61,15 @@ dns_cf_add(){ ...@@ -61,15 +61,15 @@ dns_cf_add(){
_err "Add txt record error." _err "Add txt record error."
else else
_info "Updating record" _info "Updating record"
record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \"| head -n 1) record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | head -n 1)
_debug "record_id" $record_id _debug "record_id" "$record_id"
_cf_rest PUT "zones/$_domain_id/dns_records/$record_id" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"zone_id\":\"$_domain_id\",\"zone_name\":\"$_domain\"}" _cf_rest PUT "zones/$_domain_id/dns_records/$record_id" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"zone_id\":\"$_domain_id\",\"zone_name\":\"$_domain\"}"
if [ "$?" = "0" ]; then if [ "$?" = "0" ]; then
_info "Updated, sleeping 10 seconds" _info "Updated, sleeping 10 seconds"
sleep 10 sleep 10
#todo: check if the record takes effect #todo: check if the record takes effect
return 0; return 0
fi fi
_err "Update error" _err "Update error"
return 1 return 1
...@@ -77,14 +77,12 @@ dns_cf_add(){ ...@@ -77,14 +77,12 @@ dns_cf_add(){
} }
#fulldomain #fulldomain
dns_cf_rm() { dns_cf_rm() {
fulldomain=$1 fulldomain=$1
} }
#################### Private functions bellow ################################## #################### Private functions bellow ##################################
#_acme-challenge.www.domain.com #_acme-challenge.www.domain.com
#returns #returns
...@@ -95,28 +93,28 @@ _get_root() { ...@@ -95,28 +93,28 @@ _get_root() {
domain=$1 domain=$1
i=2 i=2
p=1 p=1
while [ '1' ] ; do while true; do
h=$(printf $domain | cut -d . -f $i-100) h=$(printf "%s" "$domain" | cut -d . -f $i-100)
if [ -z "$h" ] ; then if [ -z "$h" ]; then
#not valid #not valid
return 1; return 1
fi fi
if ! _cf_rest GET "zones?name=$h" ; then if ! _cf_rest GET "zones?name=$h"; then
return 1 return 1
fi fi
if printf $response | grep \"name\":\"$h\" >/dev/null ; then if printf "%s" "$response" | grep "\"name\":\"$h\"" >/dev/null; then
_domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | head -n 1 | cut -d : -f 2 | tr -d \") _domain_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\"" | head -n 1 | cut -d : -f 2 | tr -d \")
if [ "$_domain_id" ] ; then if [ "$_domain_id" ]; then
_sub_domain=$(printf $domain | cut -d . -f 1-$p) _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
_domain=$h _domain=$h
return 0 return 0
fi fi
return 1 return 1
fi fi
p=$i p=$i
i=$(expr $i + 1) i=$(_math "$i" + 1)
done done
return 1 return 1
} }
...@@ -125,25 +123,23 @@ _cf_rest() { ...@@ -125,25 +123,23 @@ _cf_rest() {
m=$1 m=$1
ep="$2" ep="$2"
data="$3" data="$3"
_debug $ep _debug "$ep"
_H1="X-Auth-Email: $CF_Email" _H1="X-Auth-Email: $CF_Email"
_H2="X-Auth-Key: $CF_Key" _H2="X-Auth-Key: $CF_Key"
_H3="Content-Type: application/json" _H3="Content-Type: application/json"
if [ "$data" ] ; then if [ "$data" ]; then
_debug data "$data" _debug data "$data"
response="$(_post "$data" "$CF_Api/$ep" "" $m)" response="$(_post "$data" "$CF_Api/$ep" "" "$m")"
else else
response="$(_get "$CF_Api/$ep")" response="$(_get "$CF_Api/$ep")"
fi fi
if [ "$?" != "0" ] ; then if [ "$?" != "0" ]; then
_err "error $ep" _err "error $ep"
return 1 return 1
fi fi
_debug2 response "$response" _debug2 response "$response"
return 0 return 0
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#Which will be called by acme.sh to add the txt record to your api system. #Which will be called by acme.sh to add the txt record to your api system.
#returns 0 means success, otherwise error. #returns 0 means success, otherwise error.
######## Public functions ##################### ######## Public functions #####################
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" #Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
...@@ -15,21 +13,18 @@ dns_myapi_add() { ...@@ -15,21 +13,18 @@ dns_myapi_add() {
fulldomain=$1 fulldomain=$1
txtvalue=$2 txtvalue=$2
_err "Not implemented!" _err "Not implemented!"
return 1; return 1
} }
#fulldomain #fulldomain
dns_myapi_rm() { dns_myapi_rm() {
fulldomain=$1 fulldomain=$1
} }
#################### Private functions bellow ################################## #################### Private functions bellow ##################################
_info() { _info() {
if [ -z "$2" ] ; then if [ -z "$2" ]; then
echo "[$(date)] $1" echo "[$(date)] $1"
else else
echo "[$(date)] $1='$2'" echo "[$(date)] $1='$2'"
...@@ -42,7 +37,7 @@ _err() { ...@@ -42,7 +37,7 @@ _err() {
} }
_debug() { _debug() {
if [ -z "$DEBUG" ] ; then if [ -z "$DEBUG" ]; then
return return
fi fi
_err "$@" _err "$@"
...@@ -50,7 +45,7 @@ _debug() { ...@@ -50,7 +45,7 @@ _debug() {
} }
_debug2() { _debug2() {
if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ] ; then if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
_debug "$@" _debug "$@"
fi fi
return return
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment