mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-12-28 07:02:13 +08:00
Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2f0178fab | ||
|
|
326c386b2e | ||
|
|
6e68c4e2d6 | ||
|
|
a79e96802f | ||
|
|
65b22b493c | ||
|
|
253bf776b5 | ||
|
|
eef4acd07d | ||
|
|
8e845d9f21 | ||
|
|
d29aa43ba4 | ||
|
|
450efea191 | ||
|
|
241cfc4342 | ||
|
|
7c67e3d7e2 | ||
|
|
674790a511 | ||
|
|
4e3c82e329 | ||
|
|
df711b0ea2 | ||
|
|
1019fd9a9d | ||
|
|
8a420dd853 | ||
|
|
f8bcfeb2ab | ||
|
|
34e5beda6a | ||
|
|
6185244754 | ||
|
|
60d9509e39 | ||
|
|
ded4469efe | ||
|
|
1f95d8eedf | ||
|
|
aa66dfff57 | ||
|
|
25263ce40f | ||
|
|
e85deb54e1 | ||
|
|
4750fd159e | ||
|
|
7eea9533e8 | ||
|
|
ec675b9ad2 | ||
|
|
486e77f474 | ||
|
|
048059ba1f | ||
|
|
ed3dda7da9 | ||
|
|
fa93d68b08 | ||
|
|
4e20d89d9c | ||
|
|
b420ec6cb9 | ||
|
|
375f6101e9 | ||
|
|
2844d73dc7 | ||
|
|
6c1176f853 | ||
|
|
df037db0bb | ||
|
|
949cc7d21b | ||
|
|
9244529007 | ||
|
|
319d49ddbe | ||
|
|
96fcfdb6c6 | ||
|
|
d61ef6b49a | ||
|
|
804a6c8d47 | ||
|
|
c487cd6af2 |
10
Dockerfile
10
Dockerfile
@@ -4,17 +4,17 @@ RUN apk update -f \
|
||||
&& apk --no-cache add -f \
|
||||
openssl \
|
||||
curl \
|
||||
netcat-openbsd
|
||||
netcat-openbsd \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
ENV LE_CONFIG_HOME /acme.sh
|
||||
|
||||
ENV AUTO_UPGRADE 1
|
||||
|
||||
#Install
|
||||
RUN mkdir -p /install_acme.sh/
|
||||
ADD ./ /install_acme.sh/
|
||||
RUN cd /install_acme.sh && ([ -f /install_acme.sh/acme.sh ] && /install_acme.sh/acme.sh --install || curl https://get.acme.sh | sh)
|
||||
RUN rm -rf /install_acme.sh/
|
||||
RUN cd /install_acme.sh && ([ -f /install_acme.sh/acme.sh ] && /install_acme.sh/acme.sh --install || curl https://get.acme.sh | sh) && rm -rf /install_acme.sh/
|
||||
|
||||
|
||||
RUN ln -s /root/.acme.sh/acme.sh /usr/local/bin/acme.sh
|
||||
|
||||
@@ -55,5 +55,7 @@ else \n \
|
||||
/root/.acme.sh/acme.sh --config-home /acme.sh \"\$@\"\n \
|
||||
fi" >/entry.sh && chmod +x /entry.sh
|
||||
|
||||
VOLUME /acme.sh
|
||||
|
||||
ENTRYPOINT ["/entry.sh"]
|
||||
CMD ["--help"]
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# An ACME Shell script: acme.sh [](https://travis-ci.org/Neilpang/acme.sh)
|
||||
|
||||
[](https://gitter.im/acme-sh/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
- An ACME protocol client written purely in Shell (Unix shell) language.
|
||||
- Full ACME protocol implementation.
|
||||
- Simple, powerful and very easy to use. You only need 3 minutes to learn it.
|
||||
@@ -60,7 +62,7 @@ Twitter: [@neilpangxa](https://twitter.com/neilpangxa)
|
||||
|19|[](https://github.com/Neilpang/letest#here-are-the-latest-status)|Gentoo Linux
|
||||
|20|[](https://travis-ci.org/Neilpang/acme.sh)|Mac OSX
|
||||
|
||||
For all build statuses, check our [daily build project](https://github.com/Neilpang/acmetest):
|
||||
For all build statuses, check our [weekly build project](https://github.com/Neilpang/acmetest):
|
||||
|
||||
https://github.com/Neilpang/acmetest
|
||||
|
||||
@@ -197,7 +199,7 @@ The ownership and permission info of existing files are preserved. You may want
|
||||
|
||||
Install/copy the issued cert/key to the production Apache or Nginx path.
|
||||
|
||||
The cert will be `renewed every **60** days by default` (which is configurable). Once the cert is renewed, the Apache/Nginx service will be restarted automatically by the command: `service apache2 restart` or `service nginx restart`.
|
||||
The cert will be renewed every **60** days by default (which is configurable). Once the cert is renewed, the Apache/Nginx service will be reloaded automatically by the command: `service apache2 force-reload` or `service nginx force-reload`.
|
||||
|
||||
|
||||
# 4. Use Standalone server to issue cert
|
||||
|
||||
97
acme.sh
97
acme.sh
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
VER=2.6.9
|
||||
VER=2.7.1
|
||||
|
||||
PROJECT_NAME="acme.sh"
|
||||
|
||||
@@ -151,6 +151,13 @@ _dlg_versions() {
|
||||
echo "apache doesn't exists."
|
||||
fi
|
||||
|
||||
echo "nginx:"
|
||||
if _exists "nginx"; then
|
||||
nginx -V 2>&1
|
||||
else
|
||||
echo "nginx doesn't exists."
|
||||
fi
|
||||
|
||||
echo "nc:"
|
||||
if _exists "nc"; then
|
||||
nc -h 2>&1
|
||||
@@ -443,34 +450,48 @@ if [ "$(printf '\x41')" != 'A' ]; then
|
||||
_URGLY_PRINTF=1
|
||||
fi
|
||||
|
||||
_h2b() {
|
||||
hex=$(cat)
|
||||
i=1
|
||||
j=2
|
||||
_ESCAPE_XARGS=""
|
||||
if [ "$(printf %s '\\x41' | xargs printf)" = 'A' ]; then
|
||||
_ESCAPE_XARGS=1
|
||||
fi
|
||||
|
||||
_debug3 _URGLY_PRINTF "$_URGLY_PRINTF"
|
||||
while true; do
|
||||
if [ -z "$_URGLY_PRINTF" ]; then
|
||||
h="$(printf "%s" "$hex" | cut -c $i-$j)"
|
||||
if [ -z "$h" ]; then
|
||||
break
|
||||
fi
|
||||
printf "\x$h%s"
|
||||
_h2b() {
|
||||
if _exists xxd; then
|
||||
xxd -r -p
|
||||
return
|
||||
fi
|
||||
|
||||
hex=$(cat)
|
||||
ic=""
|
||||
jc=""
|
||||
_debug2 _URGLY_PRINTF "$_URGLY_PRINTF"
|
||||
if [ -z "$_URGLY_PRINTF" ]; then
|
||||
if [ "$_ESCAPE_XARGS" ] && _exists xargs; then
|
||||
_debug2 "xargs"
|
||||
echo "$hex" | _upper_case | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/g' | xargs printf
|
||||
else
|
||||
ic="$(printf "%s" "$hex" | cut -c $i)"
|
||||
jc="$(printf "%s" "$hex" | cut -c $j)"
|
||||
if [ -z "$ic$jc" ]; then
|
||||
break
|
||||
for h in $(echo "$hex" | _upper_case | sed 's/\([0-9A-F]\{2\}\)/ \1/g'); do
|
||||
if [ -z "$h" ]; then
|
||||
break
|
||||
fi
|
||||
printf "\x$h%s"
|
||||
done
|
||||
fi
|
||||
else
|
||||
for c in $(echo "$hex" | _upper_case | sed 's/\([0-9A-F]\)/ \1/g'); do
|
||||
if [ -z "$ic" ]; then
|
||||
ic=$c
|
||||
continue
|
||||
fi
|
||||
jc=$c
|
||||
ic="$(_h_char_2_dec "$ic")"
|
||||
jc="$(_h_char_2_dec "$jc")"
|
||||
printf '\'"$(printf "%o" "$(_math "$ic" \* 16 + $jc)")""%s"
|
||||
fi
|
||||
ic=""
|
||||
jc=""
|
||||
done
|
||||
fi
|
||||
|
||||
i="$(_math "$i" + 2)"
|
||||
j="$(_math "$j" + 2)"
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
_is_solaris() {
|
||||
@@ -1244,17 +1265,20 @@ createDomainKey() {
|
||||
fi
|
||||
|
||||
domain=$1
|
||||
length=$2
|
||||
_cdl=$2
|
||||
|
||||
if [ -z "$length" ]; then
|
||||
if [ -z "$_cdl" ]; then
|
||||
_debug "Use DEFAULT_DOMAIN_KEY_LENGTH=$DEFAULT_DOMAIN_KEY_LENGTH"
|
||||
length="$DEFAULT_DOMAIN_KEY_LENGTH"
|
||||
_cdl="$DEFAULT_DOMAIN_KEY_LENGTH"
|
||||
fi
|
||||
|
||||
_initpath "$domain" "$length"
|
||||
_initpath "$domain" "$_cdl"
|
||||
|
||||
if [ ! -f "$CERT_KEY_PATH" ] || ([ "$FORCE" ] && ! [ "$IS_RENEW" ]); then
|
||||
_createkey "$length" "$CERT_KEY_PATH"
|
||||
if _createkey "$_cdl" "$CERT_KEY_PATH"; then
|
||||
_savedomainconf Le_Keylength "$_cdl"
|
||||
_info "The domain key is here: $(__green $CERT_KEY_PATH)"
|
||||
fi
|
||||
else
|
||||
if [ "$IS_RENEW" ]; then
|
||||
_info "Domain key exists, skip"
|
||||
@@ -2562,7 +2586,7 @@ location ~ \"^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)\$\" {
|
||||
_err "write nginx conf error, but don't worry, the file is restored."
|
||||
return 1
|
||||
fi
|
||||
|
||||
_debug3 "Modified config:$(cat $FOUND_REAL_NGINX_CONF)"
|
||||
_info "nginx conf is done, let's check it again."
|
||||
if ! _exec "nginx -t" >/dev/null; then
|
||||
_exec_err
|
||||
@@ -2648,12 +2672,14 @@ _isRealNginxConf() {
|
||||
|
||||
_debug "_seg_n" "$_seg_n"
|
||||
|
||||
if [ "$(echo "$_seg_n" | _egrep_o "^ *ssl *on *;")" ]; then
|
||||
if [ "$(echo "$_seg_n" | _egrep_o "^ *ssl *on *;")" ] \
|
||||
|| [ "$(echo "$_seg_n" | _egrep_o "listen .* ssl[ |;]")" ]; then
|
||||
_debug "ssl on, skip"
|
||||
return 1
|
||||
else
|
||||
FOUND_REAL_NGINX_CONF_LN=$_fln
|
||||
_debug3 "found FOUND_REAL_NGINX_CONF_LN" "$FOUND_REAL_NGINX_CONF_LN"
|
||||
return 0
|
||||
fi
|
||||
FOUND_REAL_NGINX_CONF_LN=$_fln
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -2704,7 +2730,7 @@ _clearup() {
|
||||
_clearupdns() {
|
||||
_debug "_clearupdns"
|
||||
if [ "$dnsadded" != 1 ] || [ -z "$vlist" ]; then
|
||||
_debug "Dns not added, skip."
|
||||
_debug "skip dns."
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -4621,6 +4647,11 @@ install() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$_c_home" ] && [ "$LE_CONFIG_HOME" != "$LE_WORKING_DIR" ]; then
|
||||
_info "Using config home: $LE_CONFIG_HOME"
|
||||
_c_home="$LE_CONFIG_HOME"
|
||||
fi
|
||||
|
||||
#convert from le
|
||||
if [ -d "$HOME/.le" ]; then
|
||||
for envfile in "le.env" "le.sh.env"; do
|
||||
|
||||
@@ -140,7 +140,7 @@ Finally, make the DNS server and update Key available to `acme.sh`
|
||||
|
||||
```
|
||||
export NSUPDATE_SERVER="dns.example.com"
|
||||
export NSUPDATE_KEY="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=="
|
||||
export NSUPDATE_KEY="/path/to/your/nsupdate.key"
|
||||
```
|
||||
|
||||
Ok, let's issue a cert now:
|
||||
|
||||
@@ -122,18 +122,30 @@ dns_dynu_rm() {
|
||||
# _domain_name=domain.com
|
||||
_get_root() {
|
||||
domain=$1
|
||||
if ! _dynu_rest GET "dns/getroot/$domain"; then
|
||||
return 1
|
||||
fi
|
||||
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 ! _contains "$response" "domain_name"; then
|
||||
_debug "Domain name not found."
|
||||
return 1
|
||||
fi
|
||||
if ! _dynu_rest GET "dns/get/$h"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if _contains "$response" "\"name\":\"$h\"" >/dev/null; then
|
||||
_domain_name=$h
|
||||
_node=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
return 0
|
||||
fi
|
||||
p=$i
|
||||
i=$(_math "$i" + 1)
|
||||
done
|
||||
return 1
|
||||
|
||||
_domain_name=$(printf "%s" "$response" | tr -d "{}" | cut -d , -f 1 | cut -d : -f 2 | cut -d '"' -f 2)
|
||||
_node=$(printf "%s" "$response" | tr -d "{}" | cut -d , -f 3 | cut -d : -f 2 | cut -d '"' -f 2)
|
||||
return 0
|
||||
}
|
||||
|
||||
_get_recordid() {
|
||||
|
||||
@@ -37,7 +37,7 @@ dns_gandi_livedns_add() {
|
||||
_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"}' \
|
||||
&& _contains "$response" '{"message": "DNS Record Created"}' \
|
||||
&& _info "Add $(__green "success")"
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ _get_root() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! _contains "$response" "This service does not exist" >/dev/null; then
|
||||
if ! _contains "$response" "This service does not exist" >/dev/null && ! _contains "$response" "NOT_GRANTED_CALL" >/dev/null; then
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_domain="$h"
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user