signature_does_not_match_wrapper.go 1.0 KB

1234567891011121314151617181920212223242526272829
  1. package errors
  2. import "strings"
  3. const SignatureDostNotMatchErrorCode = "SignatureDoesNotMatch"
  4. const MessagePrefix = "Specified signature is not matched with our calculation. server string to sign is:"
  5. type SignatureDostNotMatchWrapper struct {
  6. }
  7. func (*SignatureDostNotMatchWrapper) tryWrap(error *ServerError, wrapInfo map[string]string) (bool, *ServerError) {
  8. clientStringToSign := wrapInfo["StringToSign"]
  9. if error.errorCode == SignatureDostNotMatchErrorCode && clientStringToSign != "" {
  10. message := error.message
  11. if strings.HasPrefix(message, MessagePrefix) {
  12. serverStringToSign := message[len(MessagePrefix):len(message)]
  13. if clientStringToSign == serverStringToSign {
  14. // user secret is error
  15. error.recommend = "Please check you AccessKeySecret"
  16. } else {
  17. error.recommend = "This may be a bug with the SDK and we hope you can submit this question in the " +
  18. "github issue(https://github.com/aliyun/alibaba-cloud-sdk-go/issues), thanks very much"
  19. }
  20. }
  21. return true, error
  22. } else {
  23. return false, nil
  24. }
  25. }