I’m trying to write code that reads/writes S3 Amazon buckets. So far I have managed to get the datestring accepted, but then get an error:
“The Authorization mechanism you are using is not supported. Please use AWS4-HMAC-SHA256”
Can anyone help me generate the correct signature?
Currently I use:
var hmac as string = Crypto.SHA_256(stringToSign)
var signature as string = EncodeBase64(hmac)
// Set the headers
urlConnection.RequestHeader(“Authorization”) = "AWS " + accessKey + “:” + signature
urlConnection.RequestHeader(“Date”) = dateHeader
// Send the GET request
Dim response As String = urlConnection.SendSync(“GET”, url, 30)
// Display the response
MessageBox(response)
Thank in advance for your help
Greg_O
(Greg O)
2
You’re skipping a step. Sha256 is not the same as hmac. I can’t tell from the docs whether hmac is supported on android or not.
Thanks Greg, I have changed the code to now use:
// Generate the signature
Dim hmac As string
hmac=Crypto.HMAC(secretKey,stringToSign,Crypto.HashAlgorithms.SHA2_256)
Dim signature As String = EncodeBase64(hmac)
// Set the headers
urlConnection.RequestHeader(“Authorization”) = "AWS " + accessKey + “:” + signature
urlConnection.RequestHeader(“Date”) = dateHeader
// Send the GET request
Dim response As String = urlConnection.SendSync(“GET”, url, 30)
Which compiles, but returns the same error response.
But I see I’m using SHA2_256, instead of SHA256: will retry…
SHA256 gives me the same error, so I’m still stuck.
I got one step further: using:
urlConnection.RequestHeader(“Authorization”) = “AWS4-HMC-SHA256 “+accessKey+”:”+signature
Now gives me a “Missing required header for this request”
Thanks MarkusR, I will read this and see if it helps me.