History

return AWS S3 compatible error for invalid but equal keys during key rotation (#5783)

This change let the server return the S3 error for a key rotation if the source key is not valid but equal to the destination key. This change also fixes the SSE-C error messages since AWS returns error messages ending with a '.'. Fixes #5625

Andreas Auernhammer committed 8 years ago

Commit da9f0e31 parent 73f7a982 files · +32 −22Browse files

Showing the changes to cmd/api-errors.go (1 of 2 files). Show all

Unified · Split

cmd/api-errors.go+15−7
@@ -138,6 +138,7 @@ const ( · 137 unmodified lines
138138 ErrMissingSSECustomerKey
139139 ErrMissingSSECustomerKeyMD5
140140 ErrSSECustomerKeyMD5Mismatch
141+ ErrInvalidSSECustomerParameters
141142
142143 // Bucket notification related errors.
143144 ErrEventNotification
@@ -629,7 +630,7 @@ var errorCodeResponse = map[APIErrorCode]APIError{ · 485 unmodified lines
629630 },
630631 ErrInsecureSSECustomerRequest: {
631632 Code: "InvalidRequest",
632− Description: errInsecureSSERequest.Error(),
633+ Description: "Requests specifying Server Side Encryption with Customer provided keys must be made over a secure connection.",
633634 HTTPStatusCode: http.StatusBadRequest,
634635 },
635636 ErrSSEMultipartEncrypted: {
@@ -639,7 +640,7 @@ var errorCodeResponse = map[APIErrorCode]APIError{ · 3 unmodified lines
639640 },
640641 ErrSSEEncryptedObject: {
641642 Code: "InvalidRequest",
642− Description: errEncryptedObject.Error(),
643+ Description: "The object was stored using a form of Server Side Encryption. The correct parameters must be provided to retrieve the object.",
643644 HTTPStatusCode: http.StatusBadRequest,
644645 },
645646 ErrInvalidEncryptionParameters: {
@@ -649,27 +650,32 @@ var errorCodeResponse = map[APIErrorCode]APIError{ · 3 unmodified lines
649650 },
650651 ErrInvalidSSECustomerAlgorithm: {
651652 Code: "InvalidArgument",
652− Description: errInvalidSSEAlgorithm.Error(),
653+ Description: "Requests specifying Server Side Encryption with Customer provided keys must provide a valid encryption algorithm.",
653654 HTTPStatusCode: http.StatusBadRequest,
654655 },
655656 ErrInvalidSSECustomerKey: {
656657 Code: "InvalidArgument",
657− Description: errInvalidSSEKey.Error(),
658+ Description: "The secret key was invalid for the specified algorithm.",
658659 HTTPStatusCode: http.StatusBadRequest,
659660 },
660661 ErrMissingSSECustomerKey: {
661662 Code: "InvalidArgument",
662− Description: errMissingSSEKey.Error(),
663+ Description: "Requests specifying Server Side Encryption with Customer provided keys must provide an appropriate secret key.",
663664 HTTPStatusCode: http.StatusBadRequest,
664665 },
665666 ErrMissingSSECustomerKeyMD5: {
666667 Code: "InvalidArgument",
667− Description: errMissingSSEKeyMD5.Error(),
668+ Description: "Requests specifying Server Side Encryption with Customer provided keys must provide the client calculated MD5 of the secret key.",
668669 HTTPStatusCode: http.StatusBadRequest,
669670 },
670671 ErrSSECustomerKeyMD5Mismatch: {
671672 Code: "InvalidArgument",
672− Description: errSSEKeyMD5Mismatch.Error(),
673+ Description: "The calculated MD5 hash of the key did not match the hash that was provided.",
674+ HTTPStatusCode: http.StatusBadRequest,
675+ },
676+ ErrInvalidSSECustomerParameters: {
677+ Code: "InvalidArgument",
678+ Description: "The provided encryption parameters did not match the ones used originally.",
673679 HTTPStatusCode: http.StatusBadRequest,
674680 },
675681
@@ -884,6 +890,8 @@ func toAPIErrorCode(err error) (apiErr APIErrorCode) { · 208 unmodified lines
884890 return ErrObjectTampered
885891 case errEncryptedObject:
886892 return ErrSSEEncryptedObject
893+ case errInvalidSSEParameters:
894+ return ErrInvalidSSECustomerParameters
887895 case errSSEKeyMismatch:
888896 return ErrAccessDenied // no access without correct key
889897 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t