TTLabs / EvaporateJS

Javascript library for browser to S3 multipart resumable uploads
1.82k stars 207 forks source link

Always get 403 SignatureDoesNotMatch error after resuming #481

Open mehranrezaei opened 2 years ago

mehranrezaei commented 2 years ago

I use this library in full compliance with official documentation and examples. My server side program works properly for signing v4, and the upload is done properly. But I have a problem with the pause and resume functions. When I pause an upload, after resuming it, the first PUT request always gets a 403 (SignatureDoesNotMatch) error. After a bit more research, it seems that the reason is that the library sends the wrong stringToSign to the server for signing on the first attempt after the resume.

This is last str_to_sign before pausing

AWS4-HMAC-SHA256 
_20220608T114339Z_ 
20220608/default/s3/aws4_request 
**b45c4ca1a7c7744ea2f3b6507bd3452317773cf30b860f4d98de662b8f7a85b6**

This is the first str_to_sign after resuming

AWS4-HMAC-SHA256
_20220608T114345Z_
20220608/default/s3/aws4_request
**b45c4ca1a7c7744ea2f3b6507bd3452317773cf30b860f4d98de662b8f7a85b6**

As you can see above the time has been changed but the canonicalRequest values are the same.

mehranrezaei commented 2 years ago

@bikeath1337 @jakubzitny Please help!

armanforghani commented 2 years ago

The line 1815 of evaporate.js should be deleted. if (typeof this._cr !== 'undefined') { return this._cr; }

mehranrezaei commented 2 years ago

@armanforghani Thanks a lot. By removing that line my problem has been resolved.

armanforghani commented 2 years ago

You can create a PR to fix this issue.