Open scambra opened 4 years ago
Ok, so there's definitely a difference between S3 and some other services. Take GameLift as an example. The signatureversion
for GameLift says "v4":
https://github.com/britzl/aws-sdk-lua/blob/master/apis/gamelift-2015-10-01.normal.json#L10
While for S3 signatureversion
it says "s3":
https://github.com/britzl/aws-sdk-lua/blob/master/apis/s3-2006-03-01.normal.json#L12
The Javascript SDK has all of the signing implementations here:
https://github.com/aws/aws-sdk-js/blob/master/lib/signers/s3.js
There is likely something wrong here:
https://github.com/britzl/aws-sdk-lua/blob/master/aws-sdk/core/request_signer.lua#L182-L185
Compare the Javascript version with the Lua version and see if you can find the problem!
It's probably also a good idea to put the code for each signing implementation into separate Lua modules.
I tried to find difference with ruby and js libraries, but I couldn't. Although I was checking v4.js because I saw a test for s3 service: https://github.com/aws/aws-sdk-js/blob/master/lib/signers/v4.js#L182
However, I have given up with this and wrote a ruby script using aws API, and I call ruby script from lua. I have more experience in ruby and I get it working right now, I don't have that lua script anymore.
I have tested this method with upload file to S3, and I get error (Code: SignatureDoesNotMatch, Message: The request signature we calculated does not match the signature you provided. Check your key and signing method.)
However, I don't see why signature is wrong, signing is working for GET requests. Error response has CanonicalRequest and StringToSign, canonical request matches with calculated value in request_signers.lua, but string to sign has different hash for canonical request.
Do you see what's wrong?