mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
catch crypto.* errors and add SSE-S3 invalid algorithm err (#6229)
This commit adds the crypto.* errors to the `toAPIErrorCode` switch. Further this commit adds an S3 API error code returned whenever the client specifes a SSE-S3 request with an invalid algorithm parameter.
This commit is contained in:
parent
bd2b22572f
commit
a078703214
@ -22,6 +22,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/minio/minio/cmd/crypto"
|
||||||
"github.com/minio/minio/pkg/auth"
|
"github.com/minio/minio/pkg/auth"
|
||||||
"github.com/minio/minio/pkg/dns"
|
"github.com/minio/minio/pkg/dns"
|
||||||
"github.com/minio/minio/pkg/event"
|
"github.com/minio/minio/pkg/event"
|
||||||
@ -129,6 +130,9 @@ const (
|
|||||||
ErrInvalidPrefixMarker
|
ErrInvalidPrefixMarker
|
||||||
// Add new error codes here.
|
// Add new error codes here.
|
||||||
|
|
||||||
|
// SSE-S3 related API errors
|
||||||
|
ErrInvalidEncryptionMethod
|
||||||
|
|
||||||
// Server-Side-Encryption (with Customer provided key) related API errors.
|
// Server-Side-Encryption (with Customer provided key) related API errors.
|
||||||
ErrInsecureSSECustomerRequest
|
ErrInsecureSSECustomerRequest
|
||||||
ErrSSEMultipartEncrypted
|
ErrSSEMultipartEncrypted
|
||||||
@ -629,6 +633,11 @@ var errorCodeResponse = map[APIErrorCode]APIError{
|
|||||||
Description: "Your metadata headers exceed the maximum allowed metadata size.",
|
Description: "Your metadata headers exceed the maximum allowed metadata size.",
|
||||||
HTTPStatusCode: http.StatusBadRequest,
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
},
|
},
|
||||||
|
ErrInvalidEncryptionMethod: {
|
||||||
|
Code: "InvalidRequest",
|
||||||
|
Description: "The encryption method specified is not supported",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
ErrInsecureSSECustomerRequest: {
|
ErrInsecureSSECustomerRequest: {
|
||||||
Code: "InvalidRequest",
|
Code: "InvalidRequest",
|
||||||
Description: "Requests specifying Server Side Encryption with Customer provided keys must be made over a secure connection.",
|
Description: "Requests specifying Server Side Encryption with Customer provided keys must be made over a secure connection.",
|
||||||
@ -866,17 +875,19 @@ func toAPIErrorCode(err error) (apiErr APIErrorCode) {
|
|||||||
case auth.ErrInvalidSecretKeyLength:
|
case auth.ErrInvalidSecretKeyLength:
|
||||||
apiErr = ErrAdminInvalidSecretKey
|
apiErr = ErrAdminInvalidSecretKey
|
||||||
// SSE errors
|
// SSE errors
|
||||||
|
case crypto.ErrInvalidEncryptionMethod:
|
||||||
|
apiErr = ErrInvalidEncryptionMethod
|
||||||
case errInsecureSSERequest:
|
case errInsecureSSERequest:
|
||||||
apiErr = ErrInsecureSSECustomerRequest
|
apiErr = ErrInsecureSSECustomerRequest
|
||||||
case errInvalidSSEAlgorithm:
|
case errInvalidSSEAlgorithm, crypto.ErrInvalidCustomerAlgorithm:
|
||||||
apiErr = ErrInvalidSSECustomerAlgorithm
|
apiErr = ErrInvalidSSECustomerAlgorithm
|
||||||
case errInvalidSSEKey:
|
case errInvalidSSEKey, crypto.ErrInvalidCustomerKey:
|
||||||
apiErr = ErrInvalidSSECustomerKey
|
apiErr = ErrInvalidSSECustomerKey
|
||||||
case errMissingSSEKey:
|
case errMissingSSEKey, crypto.ErrMissingCustomerKey:
|
||||||
apiErr = ErrMissingSSECustomerKey
|
apiErr = ErrMissingSSECustomerKey
|
||||||
case errMissingSSEKeyMD5:
|
case errMissingSSEKeyMD5, crypto.ErrMissingCustomerKeyMD5:
|
||||||
apiErr = ErrMissingSSECustomerKeyMD5
|
apiErr = ErrMissingSSECustomerKeyMD5
|
||||||
case errSSEKeyMD5Mismatch:
|
case errSSEKeyMD5Mismatch, crypto.ErrCustomerKeyMD5Mismatch:
|
||||||
apiErr = ErrSSECustomerKeyMD5Mismatch
|
apiErr = ErrSSECustomerKeyMD5Mismatch
|
||||||
case errObjectTampered:
|
case errObjectTampered:
|
||||||
apiErr = ErrObjectTampered
|
apiErr = ErrObjectTampered
|
||||||
@ -990,6 +1001,8 @@ func toAPIErrorCode(err error) (apiErr APIErrorCode) {
|
|||||||
apiErr = ErrUnsupportedNotification
|
apiErr = ErrUnsupportedNotification
|
||||||
case BackendDown:
|
case BackendDown:
|
||||||
apiErr = ErrBackendDown
|
apiErr = ErrBackendDown
|
||||||
|
case crypto.Error:
|
||||||
|
apiErr = ErrObjectTampered
|
||||||
default:
|
default:
|
||||||
apiErr = ErrInternalError
|
apiErr = ErrInternalError
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user