diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 4fe7eac8c..e8e2e573e 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -2648,8 +2648,20 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http } etag := partInfo.ETag - if isEncrypted { - etag = tryDecryptETag(objectEncryptionKey[:], partInfo.ETag, crypto.SSEC.IsRequested(r.Header)) + switch kind, encrypted := crypto.IsEncrypted(mi.UserDefined); { + case encrypted: + switch kind { + case crypto.S3: + w.Header().Set(xhttp.AmzServerSideEncryption, xhttp.AmzEncryptionAES) + etag = tryDecryptETag(objectEncryptionKey[:], etag, false) + case crypto.SSEC: + w.Header().Set(xhttp.AmzServerSideEncryptionCustomerAlgorithm, r.Header.Get(xhttp.AmzServerSideEncryptionCustomerAlgorithm)) + w.Header().Set(xhttp.AmzServerSideEncryptionCustomerKeyMD5, r.Header.Get(xhttp.AmzServerSideEncryptionCustomerKeyMD5)) + + if len(etag) >= 32 && strings.Count(etag, "-") != 1 { + etag = etag[len(etag)-32:] + } + } } // We must not use the http.Header().Set method here because some (broken)