mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-04-29 19:32:45 +00:00
Merge 58de112f932610a435e9b2d4ef8010592b6d1c67 into 40b6db6a2715628aa977ed1853fe5256704010ae
This commit is contained in:
commit
5886d18e0e
@ -15,6 +15,13 @@ TRANSIP_Token_Expiration="30 minutes"
|
||||
# You can't reuse a label token, so we leave this empty normally
|
||||
TRANSIP_Token_Label=""
|
||||
|
||||
# TransIP API requires a usename and RSA private key
|
||||
# Please set the transip username environment variable:
|
||||
# - TRANSIP_Username: The username of the transip API account
|
||||
# In addition to the username one of the following two environment variables is required:
|
||||
# - TRANSIP_Key_File: Path to a file containing the private key in PEM format; or
|
||||
# - TRANSIP_Key : The private key in PEM format
|
||||
|
||||
######## Public functions #####################
|
||||
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||
dns_transip_add() {
|
||||
@ -112,9 +119,13 @@ _transip_get_token() {
|
||||
data="{\"login\":\"${TRANSIP_Username}\",\"nonce\":\"${nonce}\",\"read_only\":\"${TRANSIP_Token_Read_Only}\",\"expiration_time\":\"${TRANSIP_Token_Expiration}\",\"label\":\"${TRANSIP_Token_Label}\",\"global_key\":\"${TRANSIP_Token_Global_Key:-false}\"}"
|
||||
_debug data "$data"
|
||||
|
||||
#_signature=$(printf "%s" "$data" | openssl dgst -sha512 -sign "$TRANSIP_Key_File" | _base64)
|
||||
_signature=$(printf "%s" "$data" | _sign "$TRANSIP_Key_File" "sha512")
|
||||
_debug2 _signature "$_signature"
|
||||
_tmp_file=$(_mktemp)
|
||||
if [ -f "$_tmp_file" ]; then
|
||||
printf '%s' "$TRANSIP_Key" >"$_tmp_file"
|
||||
_signature=$(printf "%s" "$data" | _sign "$_tmp_file" "sha512")
|
||||
_debug2 _signature "$_signature"
|
||||
rm -f "$_tmp_file"
|
||||
fi
|
||||
|
||||
export _H1="Signature: $_signature"
|
||||
export _H2="Content-Type: application/json"
|
||||
@ -129,6 +140,7 @@ _transip_get_token() {
|
||||
if _contains "$response" "token"; then
|
||||
_token="$(echo "$response" | _normalizeJson | sed -n 's/^{"token":"\(.*\)"}/\1/p')"
|
||||
_debug _token "$_token"
|
||||
_info "$(__green Successfully) authenticated with TransIP API."
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
@ -140,43 +152,66 @@ _transip_setup() {
|
||||
# retrieve the transip creds
|
||||
TRANSIP_Username="${TRANSIP_Username:-$(_readaccountconf_mutable TRANSIP_Username)}"
|
||||
TRANSIP_Key_File="${TRANSIP_Key_File:-$(_readaccountconf_mutable TRANSIP_Key_File)}"
|
||||
TRANSIP_Key="${TRANSIP_Key:-$(_readaccountconf_mutable TRANSIP_Key)}"
|
||||
# check their vals for null
|
||||
if [ -z "$TRANSIP_Username" ] || [ -z "$TRANSIP_Key_File" ]; then
|
||||
if [ -z "$TRANSIP_Username" ] || { [ -z "$TRANSIP_Key_File" ] && [ -z "$TRANSIP_Key" ] ; }; then
|
||||
TRANSIP_Username=""
|
||||
TRANSIP_Key_File=""
|
||||
_err "You didn't specify a TransIP username and api key file location"
|
||||
TRANSIP_Key=""
|
||||
_err "You didn't specify a TransIP username and/or api key file location or api key variable"
|
||||
_err "Please set those values and try again."
|
||||
return 1
|
||||
fi
|
||||
# save the username and api key to the account conf file.
|
||||
_saveaccountconf_mutable TRANSIP_Username "$TRANSIP_Username"
|
||||
_saveaccountconf_mutable TRANSIP_Key_File "$TRANSIP_Key_File"
|
||||
|
||||
# download key file if it's an URL
|
||||
if _startswith "$TRANSIP_Key_File" "http"; then
|
||||
_debug "download transip key file"
|
||||
TRANSIP_Key_URL=$TRANSIP_Key_File
|
||||
TRANSIP_Key_File="$(_mktemp)"
|
||||
chmod 600 "$TRANSIP_Key_File"
|
||||
if ! _get "$TRANSIP_Key_URL" >"$TRANSIP_Key_File"; then
|
||||
_err "Error getting key file from : $TRANSIP_Key_URL"
|
||||
_saveaccountconf_mutable TRANSIP_Username "$TRANSIP_Username"
|
||||
|
||||
if [ -z "$TRANSIP_Key" ]; then
|
||||
_clearaccountconf_mutable TRANSIP_Key
|
||||
|
||||
# download key file if it's an URL
|
||||
if _startswith "$TRANSIP_Key_File" "http"; then
|
||||
_debug "download transip key file"
|
||||
TRANSIP_Key_URL=$TRANSIP_Key_File
|
||||
TRANSIP_Key_File="$(_mktemp)"
|
||||
chmod 600 "$TRANSIP_Key_File"
|
||||
if ! _get "$TRANSIP_Key_URL" >"$TRANSIP_Key_File"; then
|
||||
_err "Error getting key file from : $TRANSIP_Key_URL"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "$TRANSIP_Key_File" ]; then
|
||||
if ! grep "BEGIN PRIVATE KEY" "$TRANSIP_Key_File" >/dev/null 2>&1; then
|
||||
_err "Key file doesn't seem to be a valid key: ${TRANSIP_Key_File}"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
_err "Can't read private key file: ${TRANSIP_Key_File}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$TRANSIP_Key_File" ] && [ -f "$TRANSIP_Key_File" ]; then
|
||||
_debug "Reading TRANSIP_Key_File value from: $TRANSIP_Key_File"
|
||||
TRANSIP_Key=$(_base64 <"$TRANSIP_Key_File")
|
||||
_saveaccountconf_mutable TRANSIP_Key "$TRANSIP_Key"
|
||||
else
|
||||
_err "Can't read private key file: ${TRANSIP_Key_File}"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "$TRANSIP_Key_File" ]; then
|
||||
if ! grep "BEGIN PRIVATE KEY" "$TRANSIP_Key_File" >/dev/null 2>&1; then
|
||||
_err "Key file doesn't seem to be a valid key: ${TRANSIP_Key_File}"
|
||||
return 1
|
||||
fi
|
||||
if [ "$(printf "%s\n" "$TRANSIP_Key" | wc -l)" -eq 1 ]; then
|
||||
TRANSIP_Key=$(printf "%s" "$TRANSIP_Key" | _dbase64)
|
||||
else
|
||||
_err "Can't read private key file: ${TRANSIP_Key_File}"
|
||||
return 1
|
||||
TRANSIP_Key=$(printf "%s" "$TRANSIP_Key" | _base64)
|
||||
_saveaccountconf_mutable TRANSIP_Key "$TRANSIP_Key"
|
||||
fi
|
||||
|
||||
if [ -z "$_token" ]; then
|
||||
if ! _transip_get_token; then
|
||||
_err "Can not get token."
|
||||
_debug "TRANSIP_Username: $TRANSIP_Username"
|
||||
_debug "TRANSIP_Key: $TRANSIP_Key"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user