From 20a6ab3d1a8b4ee0d2bf58388cf8d5a1d473cb41 Mon Sep 17 00:00:00 2001 From: neilpang Date: Mon, 7 Nov 2016 20:59:10 +0800 Subject: [PATCH 1/2] find hook file in current dir first --- acme.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/acme.sh b/acme.sh index b07b1dcd..e077d2e6 100755 --- a/acme.sh +++ b/acme.sh @@ -2297,8 +2297,12 @@ _findHook() { _hookdomain="$1" _hookcat="$2" _hookname="$3" - - if [ -f "$LE_WORKING_DIR/$_hookdomain/$_hookname" ] ; then + + if [ -f "$_SCRIPT_HOME/$_hookdomain/$_hookname" ] ; then + d_api="$_SCRIPT_HOME/$_hookdomain/$_hookname" + elif [ -f "$_SCRIPT_HOME/$_hookdomain/$_hookname.sh" ] ; then + d_api="$_SCRIPT_HOME/$_hookdomain/$_hookname.sh" + elif [ -f "$LE_WORKING_DIR/$_hookdomain/$_hookname" ] ; then d_api="$LE_WORKING_DIR/$_hookdomain/$_hookname" elif [ -f "$LE_WORKING_DIR/$_hookdomain/$_hookname.sh" ] ; then d_api="$LE_WORKING_DIR/$_hookdomain/$_hookname.sh" From b001840dee20d31423a7fb29e18ac9177b7f9a4c Mon Sep 17 00:00:00 2001 From: neilpang Date: Tue, 8 Nov 2016 21:27:39 +0800 Subject: [PATCH 2/2] minor: add _hmac function --- acme.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/acme.sh b/acme.sh index e077d2e6..c52ce70c 100755 --- a/acme.sh +++ b/acme.sh @@ -436,6 +436,31 @@ _digest() { } +#Usage: hashalg secret [outputhex] +#Output Base64-encoded hmac +_hmac() { + alg="$1" + hmac_sec="$2" + outputhex="$3" + + if [ -z "$hmac_sec" ] ; then + _usage "Usage: _hmac hashalg secret [outputhex]" + return 1 + fi + + if [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ]; then + if [ "$outputhex" ] ; then + openssl dgst -$alg -hmac "$hmac_sec" | cut -d = -f 2 | tr -d ' ' + else + openssl dgst -$alg -hmac "$hmac_sec" -binary | _base64 + fi + else + _err "$alg is not supported yet" + return 1 + fi + +} + #Usage: keyfile hashalg #Output: Base64-encoded signature value _sign() {