Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this specifically be for presigned operations? - why is it done for regular signature V4. When there is no data it should be calculated as "sha256" of an empty byte array.
http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, actually this is unrelated to presigned url.
i.e the following code gives error without this fix:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meaning, for presignedPUT the gateway calls:
Core.PutObject() with sha256bytes as empty byte array
Now minio-go sets SHA256 header as Hex(SHA256Hash("")) because of the bug instead of UNSIGNED-PAYLOAD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we are breaking backward compatibility here. The example is wrong it is expected in signature-v4 for PUT you are passing in the payload checksum. So setting it as
nil
is wrong.What should be set is perhaps
[]byte("UNSIGNED-PAYLOAD")
is passed in from PutObject() perspective indicating that the payload checksum is going to be unsigned and internal code differentiates this.Otherwise we are breaking backward compatibility i.e for some servers which do not implement UNSIGNED-PAYLOAD verification for GET, HEAD operations would lead to signature issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krishnasrinivas It is not wrong to compute sha256 sum of
[]byte{}
and setx-amz-content-sha256
header with it. SeeImportant section
here http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html.UNSIGNED-PAYLOAD
is an alternate. So, the server should work with requests signed using either of the approaches.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but even without this fix, for secure connections, we are sending UNSIGNED-PAYLOAD for GET/HEAD, take a look at this:
But I see what you mean here, minio-js was written such that it uses UNSIGNED-PAYLOAD only for "upload object" operations.
It can be fixed in a cleaner way if we want to fix it. i.e
metadata.contentSHA256Bytes
beingnil
should not indicate whether the body itself is empty. If the body is empty the caller should setmetadata.contentSHA256Bytes
toHex(SHA256Hash(""))
and Ifmetadata.contentSHA256Bytes
is set to nil then we simple useUNSIGNED-PAYLOAD
Ofcourse. This commit does not counter that fact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. This is completely different from what I was referring to.
UNSIGNED-PAYLOAD
got me.