Skip to content

Commit

Permalink
added check for missing kms key id
Browse files Browse the repository at this point in the history
Signed-off-by: AvivGuiser <[email protected]>
  • Loading branch information
KyriosGN0 committed Aug 3, 2024
1 parent 41e230c commit 1ebae80
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tempodb/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func internalNew(cfg *Config, confirm bool) (*readerWriter, error) {
core: core,
hedgedCore: hedgedCore,
}

return rw, nil
}

Expand Down Expand Up @@ -706,7 +707,7 @@ func parseKMSEncryptionContext(data string) (map[string]string, error) {
}

decoded := map[string]string{}
err := fmt.Errorf("unable to parse KMS encryption context %w", json.Unmarshal([]byte(data), &decoded))
err := json.Unmarshal([]byte(data), &decoded)
return decoded, err
}

Expand All @@ -715,16 +716,20 @@ func buildSSEConfig(cfg *Config) (encrypt.ServerSide, error) {
case "":
return nil, nil
case SSEKMS:
encryptionCtx, err := parseKMSEncryptionContext(cfg.SSE.KMSEncryptionContext)
if err != nil {
return nil, err
}
if cfg.SSE.KMSKeyID == "" {
return nil, errors.New("KMSKeyID is missing")
} else {
encryptionCtx, err := parseKMSEncryptionContext(cfg.SSE.KMSEncryptionContext)
if err != nil {
return nil, err
}
if encryptionCtx == nil {
// To overcome a limitation in Minio which checks interface{} == nil.

if encryptionCtx == nil {
// To overcome a limitation in Minio which checks interface{} == nil.
return encrypt.NewSSEKMS(cfg.SSE.KMSKeyID, nil)
return encrypt.NewSSEKMS(cfg.SSE.KMSKeyID, nil)
}
return encrypt.NewSSEKMS(cfg.SSE.KMSKeyID, encryptionCtx)
}
return encrypt.NewSSEKMS(cfg.SSE.KMSKeyID, encryptionCtx)
case SSES3:
return encrypt.NewSSE(), nil
default:
Expand Down

0 comments on commit 1ebae80

Please sign in to comment.