@ -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
}
}