3636# variable __IP already defined with the ip-address to use for update
3737#
3838
39+ local OPENSSL=$( command -v openssl)
40+
3941# check parameters
4042[ -z " $username " ] && write_log 14 " Service section not configured correctly! Missing key as 'username'"
4143[ -z " $password " ] && write_log 14 " Service section not configured correctly! Missing secret as 'password'"
4244[ -z " $CURL_SSL " ] && write_log 13 " Dnspod communication require cURL with SSL support. Please install"
45+ [ -z " $OPENSSL " ] && write_log 13 " Dnspod communication require openssl. Please install"
4346[ $use_https -eq 0 ] && use_https=1
4447
4548# variables
@@ -179,7 +182,7 @@ x-tc-action:$(echo $__ACTION | awk '{print tolower($0)}')
179182EOF
180183 )
181184 local __SIGNED_HEADERS=" content-type;host;x-tc-action"
182- local __HASHED_REQUEST_PAYLOAD=$( echo -n " $__PAYLOAD " | openssl sha256 -hex | awk ' {print $2}' )
185+ local __HASHED_REQUEST_PAYLOAD=$( echo -n " $__PAYLOAD " | $OPENSSL sha256 -hex | awk ' {print $2}' )
183186 local __CANONICAL_REQEUST=$(
184187 cat << EOF
185188$__METHOD
195198 # 步骤 2:拼接待签名字符串
196199 local __CREDENTIAL_SCOPE=" $__DATE /$__SERVICE /tc3_request"
197200 local __HASHED_CANONICAL_REQUEST=$( printf " $__CANONICAL_REQEUST " |
198- openssl sha256 -hex | awk ' {print $2}' )
201+ $OPENSSL sha256 -hex | awk ' {print $2}' )
199202 local __STRING_TO_SIGN=$(
200203 cat << EOF
201204$__ALGORITHM
@@ -207,13 +210,13 @@ EOF
207210
208211 # 步骤 3:计算签名
209212 local __SECRET_DATE=$( printf " $__DATE " |
210- openssl sha256 -hmac " TC3$__SECRET_KEY " | awk ' {print $2}' )
213+ $OPENSSL sha256 -hmac " TC3$__SECRET_KEY " | awk ' {print $2}' )
211214 local __SECRET_SERVICE=$( printf $__SERVICE |
212- openssl dgst -sha256 -mac hmac -macopt hexkey:" $__SECRET_DATE " | awk ' {print $2}' )
215+ $OPENSSL dgst -sha256 -mac hmac -macopt hexkey:" $__SECRET_DATE " | awk ' {print $2}' )
213216 local __SECRET_SIGNING=$( printf " tc3_request" |
214- openssl dgst -sha256 -mac hmac -macopt hexkey:" $__SECRET_SERVICE " | awk ' {print $2}' )
217+ $OPENSSL dgst -sha256 -mac hmac -macopt hexkey:" $__SECRET_SERVICE " | awk ' {print $2}' )
215218 local __SIGNATURE=$( printf " $__STRING_TO_SIGN " |
216- openssl dgst -sha256 -mac hmac -macopt hexkey:" $__SECRET_SIGNING " | awk ' {print $2}' )
219+ $OPENSSL dgst -sha256 -mac hmac -macopt hexkey:" $__SECRET_SIGNING " | awk ' {print $2}' )
217220
218221 # 步骤 4:拼接 Authorization
219222 local __AUTHORIZATION=" $__ALGORITHM Credential=$__SECRET_ID /$__CREDENTIAL_SCOPE , \
0 commit comments