Fix GetObject encrypted etag (#17302)

Co-authored-by: Harshavardhana <harsha@minio.io>
This commit is contained in:
Klaus Post 2023-05-31 13:10:25 -07:00 committed by GitHub
parent e53f49e9a9
commit c9e26401fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -499,18 +499,22 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
objInfo.UserDefined = objectlock.FilterObjectLockMetadata(objInfo.UserDefined, getRetPerms != ErrNone, legalHoldPerms != ErrNone) objInfo.UserDefined = objectlock.FilterObjectLockMetadata(objInfo.UserDefined, getRetPerms != ErrNone, legalHoldPerms != ErrNone)
// Set encryption response headers // Set encryption response headers
switch kind, _ := crypto.IsEncrypted(objInfo.UserDefined); kind {
case crypto.S3: if kind, isEncrypted := crypto.IsEncrypted(objInfo.UserDefined); isEncrypted {
w.Header().Set(xhttp.AmzServerSideEncryption, xhttp.AmzEncryptionAES) switch kind {
case crypto.S3KMS: case crypto.S3:
w.Header().Set(xhttp.AmzServerSideEncryption, xhttp.AmzEncryptionKMS) w.Header().Set(xhttp.AmzServerSideEncryption, xhttp.AmzEncryptionAES)
w.Header().Set(xhttp.AmzServerSideEncryptionKmsID, objInfo.KMSKeyID()) case crypto.S3KMS:
if kmsCtx, ok := objInfo.UserDefined[crypto.MetaContext]; ok { w.Header().Set(xhttp.AmzServerSideEncryption, xhttp.AmzEncryptionKMS)
w.Header().Set(xhttp.AmzServerSideEncryptionKmsContext, kmsCtx) w.Header().Set(xhttp.AmzServerSideEncryptionKmsID, objInfo.KMSKeyID())
if kmsCtx, ok := objInfo.UserDefined[crypto.MetaContext]; ok {
w.Header().Set(xhttp.AmzServerSideEncryptionKmsContext, kmsCtx)
}
case crypto.SSEC:
w.Header().Set(xhttp.AmzServerSideEncryptionCustomerAlgorithm, r.Header.Get(xhttp.AmzServerSideEncryptionCustomerAlgorithm))
w.Header().Set(xhttp.AmzServerSideEncryptionCustomerKeyMD5, r.Header.Get(xhttp.AmzServerSideEncryptionCustomerKeyMD5))
} }
case crypto.SSEC: objInfo.ETag = getDecryptedETag(r.Header, objInfo, false)
w.Header().Set(xhttp.AmzServerSideEncryptionCustomerAlgorithm, r.Header.Get(xhttp.AmzServerSideEncryptionCustomerAlgorithm))
w.Header().Set(xhttp.AmzServerSideEncryptionCustomerKeyMD5, r.Header.Get(xhttp.AmzServerSideEncryptionCustomerKeyMD5))
} }
if r.Header.Get(xhttp.AmzChecksumMode) == "ENABLED" && rs == nil { if r.Header.Get(xhttp.AmzChecksumMode) == "ENABLED" && rs == nil {