do not crash when KMS is not enabled (#14634)

KMS when not enabled might crash when listing
an object that previously had SSE-S3 enabled,
fail appropriately in such situations.
This commit is contained in:
Harshavardhana
2022-03-27 08:54:01 -07:00
committed by GitHub
parent be5d394e56
commit ecfae074dc
2 changed files with 11 additions and 0 deletions

View File

@@ -96,6 +96,10 @@ func (ssekms) IsEncrypted(metadata map[string]string) bool {
// from the metadata using KMS and returns the decrypted object
// key.
func (s3 ssekms) UnsealObjectKey(KMS kms.KMS, metadata map[string]string, bucket, object string) (key ObjectKey, err error) {
if KMS == nil {
return key, Errorf("KMS not configured")
}
keyID, kmsKey, sealedKey, ctx, err := s3.ParseMetadata(metadata)
if err != nil {
return key, err