From 2229047afdc91af8d282d2cb4c6a1a72b5db22ba Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Thu, 11 Mar 2021 15:06:28 +0800 Subject: [PATCH] fix _get --- acme.sh | 2 +- dnsapi/dns_ali.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/acme.sh b/acme.sh index bdc1bfcf..757ed7a5 100755 --- a/acme.sh +++ b/acme.sh @@ -1942,7 +1942,7 @@ _get() { fi _debug "_CURL" "$_CURL" if [ "$onlyheader" ]; then - $_CURL -X GET -I --user-agent "$USER_AGENT" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$url" + $_CURL -I --user-agent "$USER_AGENT" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$url" else $_CURL --user-agent "$USER_AGENT" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$url" fi diff --git a/dnsapi/dns_ali.sh b/dnsapi/dns_ali.sh index 68118aee..936f7c2e 100755 --- a/dnsapi/dns_ali.sh +++ b/dnsapi/dns_ali.sh @@ -87,8 +87,12 @@ _get_root() { _use_instance_role() { _url="http://100.100.100.200/latest/meta-data/ram/security-credentials/" _debug "_url" "$_url" - if ! _get "$_url" true 1 | _head_n 1 | grep -Fq 200; then - _debug "Unable to fetch IAM role from instance metadata" + + # **Do Not** set the parameter `onlyheadr` for _get, it will + # send a HEAD request instead of GET. And alicloud + # mata url not allow HEAD request. + if _get "$_url" "" 1 | grep '404 - Not Found' > /dev/null; then + _debug "Unable to fetch RAM role from instance metadata" return 1 fi _ali_instance_role=$(_get "$_url" "" 1)