问题描述
= 保证金:0px;填充:0px;边界:0px;字体样式:继承;字体变体:继承;字体重量:继承;行高:继承;字体系列:Consolas,Menlo,摩纳哥,'Lucida Console ','解放单声道','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,无衬线字体; font-size:13px; vertical-align:baseline; white-space:inherit>我正在尝试删除azure存储中的blob,但是我的curl不断返回以下错误
<?xml版本=" 1.0编码=" utf-8?<错误<代码>验证失败</代码><消息>服务器失败对请求进行身份验证,确保包括标题在内的Authorization标头的值正确形成. RequestId:XX 时间:2018-08-09T10:09:41.3394688Z</Message>< AuthenticationErrorDetail>在HTTP请求``xxx''中找到的MAC签名与任何计算出的签名都不相同.服务器使用以下字符串进行签名:'DELETE'
这是我的代码
#删除Azure存储容器中的Blob. 回声用法:$ {0 ## */}<存储帐户名> <容器名称> <访问密钥>> storage_account ="$ 1" container_name ="$ 2" access_key ="$ 3" blob_store_url =" blob.core.windows.net" 授权="SharedKey" request_method ="DELETE"; request_date = $(TZ = GMT LC_ALL = zh_CN.utf8日期"+%a,%d%h%Y%H:%M:%S%Z") #request_date ="2016年4月18日星期一05:16:09 GMT" storage_service_version ="2018-03-28"; #HTTP请求标头 x_ms_date_h =" x-ms-date:$ request_date" x_ms_version_h ="x-ms-version:$ storage_service_version" #构建签名字符串 canonicalized_headers =" $ {x_ms_date_h} \ n $ {x_ms_version_h}" canonicalized_resource ="//$ {storage_account}/$ {container_name}" string_to_sign ="$ {request_method} \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n $ {canonicalized_headers} \ n $ {canonicalized_resource} \ ncomp:list \ nrestype:container" ; #解码Base64编码的访问密钥,转换为十六进制. encoded_hex_key ="$(echo -n $ access_key | base64 -d -w0 | xxd -p -c256)" #为Authorization标头创建HMAC签名 signature = $(printf" $ string_to_sign" | openssl dgst -sha256 -mac HMAC -macopt" hexkey:$ decoded_hex_key" -binary | base64 -w0) authorization_header =授权:$ authorization $ storage_account:$ signature" 卷曲 -H" $ x_ms_date_h" \ -H"$ x_ms_version_h"; \ -H"$ authorization_header"; \ -H内容长度:0" \
X删除
"https://$ {storage_account}.$ {blob_store_url}/$ {container_name}/somefolder/myfile.csv_123""
I'm trying to delete a blob in azure storage but my curl keeps returning the error below
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:XX Time:2018-08-09T10:09:41.3394688Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'xxx' is not the same as any computed signature. Server used following string to sign: 'DELETE'
This is my code
# Delete a blobs in an Azure storage container. echo "usage: ${0##*/} <storage-account-name> <container-name> <access-key>" storage_account="$1" container_name="$2" access_key="$3" blob_store_url="blob.core.windows.net" authorization="SharedKey" request_method="DELETE" request_date=$(TZ=GMT LC_ALL=en_US.utf8 date "+%a, %d %h %Y %H:%M:%S %Z") #request_date="Mon, 18 Apr 2016 05:16:09 GMT" storage_service_version="2018-03-28" # HTTP Request headers x_ms_date_h="x-ms-date:$request_date" x_ms_version_h="x-ms-version:$storage_service_version" # Build the signature string canonicalized_headers="${x_ms_date_h}\n${x_ms_version_h}" canonicalized_resource="/${storage_account}/${container_name}" string_to_sign="${request_method}\n\n\n\n\n\n\n\n\n\n\n\n${canonicalized_headers}\n${canonicalized_resource}\ncomp:list\nrestype:container" # Decode the Base64 encoded access key, convert to Hex. decoded_hex_key="$(echo -n $access_key | base64 -d -w0 | xxd -p -c256)" # Create the HMAC signature for the Authorization header signature=$(printf "$string_to_sign" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$decoded_hex_key" -binary | base64 -w0) authorization_header="Authorization: $authorization $storage_account:$signature" curl \ -H "$x_ms_date_h" \ -H "$x_ms_version_h" \ -H "$authorization_header" \ -H "Content-Length: 0"\
X DELETE
"https://${storage_account}.${blob_store_url}/${container_name}/somefolder/myfile.csv_123"
这篇关于使用CURL删除Azure博客存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!