Skip to content

Commit

Permalink
Bucket location sends UNSIGNED-PAYLOAD with https connection (minio#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadmeste authored and harshavardhana committed Aug 9, 2016
1 parent aea0011 commit ec05bd5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R
// set sha256 sum for signature calculation only with
// signature version '4'.
if c.signature.isV4() {
shaHeader := "UNSIGNED-PAYLOAD"
shaHeader := unsignedPayload
if !c.secure {
if metadata.contentSHA256Bytes == nil {
shaHeader = hex.EncodeToString(sum256([]byte{}))
Expand Down
8 changes: 7 additions & 1 deletion bucket-cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ func (c Client) getBucketLocationRequest(bucketName string) (*http.Request, erro

// Set sha256 sum for signature calculation only with signature version '4'.
if c.signature.isV4() {
req.Header.Set("X-Amz-Content-Sha256", hex.EncodeToString(sum256([]byte{})))
var contentSha256 string
if c.secure {
contentSha256 = unsignedPayload
} else {
contentSha256 = hex.EncodeToString(sum256([]byte{}))
}
req.Header.Set("X-Amz-Content-Sha256", contentSha256)
}

// Sign the request.
Expand Down
4 changes: 4 additions & 0 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ const maxMultipartPutObjectSize = 1024 * 1024 * 1024 * 1024 * 5
// optimalReadBufferSize - optimal buffer 5MiB used for reading
// through Read operation.
const optimalReadBufferSize = 1024 * 1024 * 5

// unsignedPayload - value to be set to X-Amz-Content-Sha256 header when
// we don't want to sign the request payload
const unsignedPayload = "UNSIGNED-PAYLOAD"
2 changes: 1 addition & 1 deletion request-signature-v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func getHashedPayload(req http.Request) string {
hashedPayload := req.Header.Get("X-Amz-Content-Sha256")
if hashedPayload == "" {
// Presign does not have a payload, use S3 recommended value.
hashedPayload = "UNSIGNED-PAYLOAD"
hashedPayload = unsignedPayload
}
return hashedPayload
}
Expand Down

0 comments on commit ec05bd5

Please sign in to comment.