Skip to content

Commit

Permalink
fix bug: re-generate domain key if the key length is different.
Browse files Browse the repository at this point in the history
  • Loading branch information
neil committed Jul 2, 2016
1 parent bc96082 commit 61623d2
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions acme.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

VER=2.2.9
VER=2.3.0

PROJECT_NAME="acme.sh"

Expand Down Expand Up @@ -829,6 +829,19 @@ _cleardomainconf() {
fi
}

#_readdomainconf key
_readdomainconf() {
key="$1"
if [ "$DOMAIN_CONF" ] ; then
(
eval $(grep "^$key *=" "$DOMAIN_CONF")
eval "printf \"%s\" \"\$$key\""
)
else
_err "DOMAIN_CONF is empty, can not read $key"
fi
}

#_saveaccountconf key value
_saveaccountconf() {
key="$1"
Expand Down Expand Up @@ -1270,7 +1283,7 @@ issue() {
_initpath $Le_Domain

if [ -f "$DOMAIN_CONF" ] ; then
Le_NextRenewTime=$(grep "^Le_NextRenewTime=" "$DOMAIN_CONF" | cut -d '=' -f 2 | tr -d "'\"")
Le_NextRenewTime=$(_readdomainconf Le_NextRenewTime)
_debug Le_NextRenewTime "$Le_NextRenewTime"
if [ -z "$FORCE" ] && [ "$Le_NextRenewTime" ] && [ $(date -u "+%s" ) -lt $Le_NextRenewTime ] ; then
_info "Skip, Next renewal time is: $(grep "^Le_NextRenewTimeStr" "$DOMAIN_CONF" | cut -d '=' -f 2)"
Expand All @@ -1281,15 +1294,12 @@ issue() {
_savedomainconf "Le_Domain" "$Le_Domain"
_savedomainconf "Le_Alt" "$Le_Alt"
_savedomainconf "Le_Webroot" "$Le_Webroot"
_savedomainconf "Le_Keylength" "$Le_Keylength"


if [ "$Le_Alt" = "no" ] ; then
Le_Alt=""
fi
if [ "$Le_Keylength" = "no" ] ; then
Le_Keylength=""
fi


if _hasfield "$Le_Webroot" "no" ; then
_info "Standalone mode."
if ! _exists "nc" ; then
Expand Down Expand Up @@ -1385,14 +1395,21 @@ issue() {
_info "Skip register account key"
fi

if [ ! -f "$CERT_KEY_PATH" ] ; then
_key=$(_readdomainconf Le_Keylength)
_debug "Read key length:$_key"
if [ "$Le_Keylength" != "$_key" ] ; then
if ! createDomainKey $Le_Domain $Le_Keylength ; then
_err "Create domain key error."
_clearup
return 1
fi
fi

_savedomainconf "Le_Keylength" "$Le_Keylength"
if [ "$Le_Keylength" = "no" ] ; then
Le_Keylength=""
fi

if ! createCSR $Le_Domain $Le_Alt ; then
_err "Create CSR error."
_clearup
Expand Down

0 comments on commit 61623d2

Please sign in to comment.