您好,登錄后才能下訂單哦!
這篇文章主要講解了“AWS2認證過程怎么實現”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“AWS2認證過程怎么實現”吧!
很多新手司機看官方文檔AWS2認證部分特別是Authorization怎么生成的總是晦澀難懂,其核心就是StringToSign到底怎么構成
Authorization = "AWS" + " " + AWSAccessKeyId + ":" + Signature; Signature = Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) ); StringToSign = HTTP-Verb + "\n" + Content-MD5 + "\n" + Content-Type + "\n" + Date + "\n" + CanonicalizedAmzHeaders + CanonicalizedResource;
下面以使用bash向S3上傳一個Object為例,具體解釋一下整個AWS2的簽名過程
#!/bin/bash ACCESS_KEY="" #填access key SECRET_KEY="" #填secret key HOST="s3.cephbook.com" #填S3的Endpoint地址 BUCKET="demo" #填bucket名稱 CONTENT_TYPE="application/octet-stream" #MIME FILENAME=/tmp/demo #文件本地路徑 ACL="x-amz-acl:public-read" #Object的ACL META_DATA="x-amz-meta-ukey:value" #自定義medadata FILESIZE=$(stat -c%s "$FILENAME") FILEMD5=`cat ${FILENAME}| openssl dgst -md5 -binary | openssl enc -base64` AUTH_PATH="/${BUCKET}${FILENAME}" CURRENT_TIME=`TZ=GMT LANG=en_US date "+%a, %d %b %Y %H:%M:%S GMT"` stringToSign="PUT\n${FILEMD5}\n${CONTENT_TYPE}\n${CURRENT_TIME}\n${ACL}\n${META_DATA}\n${AUTH_PATH}" echo $stringToSign signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${SECRET_KEY} -binary | base64` curl -s -v -X PUT "http://${HOST}${AUTH_PATH}" \ -H "Authorization: AWS ${ACCESS_KEY}:${signature}" \ -H "Date: ${CURRENT_TIME}" \ -H "Host: ${HOST}" \ -H "Content-Length: ${FILESIZE}" \ -H "Content-MD5: ${FILEMD5} " \ -H "Content-Type: ${CONTENT_TYPE} " \ -H "${ACL} " \ -H "${META_DATA} " \ -T "${FILENAME}"
感謝各位的閱讀,以上就是“AWS2認證過程怎么實現”的內容了,經過本文的學習后,相信大家對AWS2認證過程怎么實現這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。