[#543] Add md5 sse-c S3Tests compatability
All checks were successful
/ DCO (pull_request) Successful in 1m25s
/ Vulncheck (pull_request) Successful in 1m37s
/ Builds (pull_request) Successful in 1m50s
/ Lint (pull_request) Successful in 2m52s
/ Tests (pull_request) Successful in 1m49s

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
Pavel Pogodaev 2024-11-15 13:20:18 +03:00
parent d8f126b339
commit 6cde68914a
2 changed files with 12 additions and 4 deletions

View file

@ -246,7 +246,7 @@ func (h *handler) DeleteBucketHandler(w http.ResponseWriter, r *http.Request) {
} }
if err = checkOwner(bktInfo, reqInfo.User); err != nil { if err = checkOwner(bktInfo, reqInfo.User); err != nil {
h.logAndSendError(w, "request owner id does not match bucket owner id", reqInfo, err) h.logAndSendError(ctx, w, "request owner id does not match bucket owner id", reqInfo, err)
return return
} }

View file

@ -224,8 +224,12 @@ func (n *Layer) uploadPart(ctx context.Context, multipartInfo *data.MultipartInf
} }
decSize := p.Size decSize := p.Size
md5Hash := md5.New()
if p.Info.Encryption.Enabled() { if p.Info.Encryption.Enabled() {
r, encSize, err := encryptionReader(p.Reader, p.Size, p.Info.Encryption.Key()) rr := wrapReader(p.Reader, 64*1024, func(buf []byte) {
md5Hash.Write(buf)
})
r, encSize, err := encryptionReader(rr, p.Size, p.Info.Encryption.Key())
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create ecnrypted reader: %w", err) return nil, fmt.Errorf("failed to create ecnrypted reader: %w", err)
} }
@ -246,7 +250,12 @@ func (n *Layer) uploadPart(ctx context.Context, multipartInfo *data.MultipartInf
if err != nil { if err != nil {
return nil, apierr.GetAPIError(apierr.ErrInvalidDigest) return nil, apierr.GetAPIError(apierr.ErrInvalidDigest)
} }
if hex.EncodeToString(hashBytes) != hex.EncodeToString(createdObj.MD5Sum) {
match := hex.EncodeToString(hashBytes) == hex.EncodeToString(createdObj.MD5Sum)
if p.Info.Encryption.Enabled() {
match = hex.EncodeToString(hashBytes) == hex.EncodeToString(md5Hash.Sum(nil))
}
if !match {
prm := frostfs.PrmObjectDelete{ prm := frostfs.PrmObjectDelete{
Object: createdObj.ID, Object: createdObj.ID,
Container: bktInfo.CID, Container: bktInfo.CID,
@ -449,7 +458,6 @@ func (n *Layer) CompleteMultipartUpload(ctx context.Context, p *CompleteMultipar
initMetadata[AttributeHMACKey] = encInfo.HMACKey initMetadata[AttributeHMACKey] = encInfo.HMACKey
initMetadata[AttributeHMACSalt] = encInfo.HMACSalt initMetadata[AttributeHMACSalt] = encInfo.HMACSalt
initMetadata[AttributeDecryptedSize] = strconv.FormatUint(multipartObjetSize, 10) initMetadata[AttributeDecryptedSize] = strconv.FormatUint(multipartObjetSize, 10)
multipartObjetSize = encMultipartObjectSize
} }
partsData, err := json.Marshal(parts) partsData, err := json.Marshal(parts)