turn-off md5sum for SSE-KMS/SSE-C as optimization for multipart (#19106)

only enable md5sum if explicitly asked by the client, otherwise
its not necessary to compute md5sum when SSE-KMS/SSE-C is enabled.

this is continuation of #17958
This commit is contained in:
Harshavardhana 2024-02-22 04:24:11 -08:00 committed by GitHub
parent 53aa8f5650
commit c32f699105
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -729,13 +729,20 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
sha256hex = "" sha256hex = ""
} }
var forceMD5 []byte
// Optimization: If SSE-KMS and SSE-C did not request Content-Md5. Use uuid as etag. Optionally enable this also
// for server that is started with `--no-compat`.
if !etag.ContentMD5Requested(r.Header) && (crypto.S3KMS.IsEncrypted(mi.UserDefined) || crypto.SSEC.IsRequested(r.Header) || !globalServerCtxt.StrictS3Compat) {
forceMD5 = mustGetUUIDBytes()
}
hashReader, err := hash.NewReaderWithOpts(ctx, reader, hash.Options{ hashReader, err := hash.NewReaderWithOpts(ctx, reader, hash.Options{
Size: size, Size: size,
MD5Hex: md5hex, MD5Hex: md5hex,
SHA256Hex: sha256hex, SHA256Hex: sha256hex,
ActualSize: actualSize, ActualSize: actualSize,
DisableMD5: false, DisableMD5: false,
ForceMD5: nil, ForceMD5: forceMD5,
}) })
if err != nil { if err != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)