【问题标题】:AWS API Gateway: Request signature we calculated does not match the signature you providedAWS API Gateway:我们计算的请求签名与您提供的签名不匹配
【发布时间】:2017-12-20 07:54:32
【问题描述】:

当我尝试通过邮递员发送请求时。我面临一些问题。我在邮递员的 aws 身份验证中设置了这个:-

"访问密钥:- xxxxxxxxxx

密钥:-xxxxxxxxxx

Aws 区域:- ap-south-1

服务名称:- execute-api"。

虽然 POST 我收到了这个错误

{ "message": "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\n\nThe Canonical String for this request should have been\n'POST\n/dms/api/v1/filestore/file\n\ncontent-length:29940\ncontent-type:multipart/form-data\nhost:e7ffona9b4.execute-api.ap-south-1.amazonaws.com\nx-amz-date:20170714T111258Z\n\ncontent-length;content-type;host;x-amz-date\n15c77e9022d5c4e9de523e7279515d245695c76115ebabe7517119701f9ae963'\n\nThe String-to-Sign should have been\n'AWS4-HMAC-SHA256\n20170714T111258Z\n20170714/ap-south-1/execute-api/aws4_request\nb0e6151f24eb3a4aa5520da442bdafe7625a44ed7c15f3109eeb78eef038a6cd'\n" }

虽然 GET 我得到了这个

{ "message": "No method found matching route api/v1/filestore/file for http method GET." }

在代码中我做了这样的事情

@RestController
@requestmapping(value = "/v1/filestore")
public class FileUploadController {

@Autowired
private IFileStoreService fileStoreService;

@CrossOrigin
@ResponseBody
@RequestMapping(value = "/file/{id}", method = RequestMethod.GET)

并在 application.properties 我设置

server.contextPath=/api

如果我错了,请引导我正确的论点并帮助我解决这个问题。

谢谢

【问题讨论】:

  • 您是否在不安全的情况下检查了您的请求?
  • 是的,我这样做了,然后也出现了同样的错误,但是当我选择 No Auth 并尝试使用邮递员发送获取请求时,{"message": "Missing Authentication Token"} 出现了。
  • 我的意思是您的服务器中没有安全模块。只需关闭安全性以简化调试,我们就可以本地化问题

标签: java amazon-web-services aws-lambda postman aws-api-gateway


【解决方案1】:

仔细检查这些:

  1. 您分配给对象的键不以句点开头。

  2. 粘贴时不应有任何不可见字符。

  3. 尝试使用encodeURIComponent()对CopySource进行编码

【讨论】:

  • 你说的是哪个键?这里的 CopySource 是什么?
【解决方案2】:

调试签名问题可能很困难,并且可能涉及多个问题。查看您的描述,这是我注意到的一个问题...

在您使用邮递员返回的错误消息中,我们有:

The request signature we calculated does not match the signature...The Canonical String for this request should have been...content-type:multipart/form-data...

API Gateway 不支持也不正确处理 multipart/form-data

【讨论】:

    猜你喜欢
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 2017-07-23
    • 1970-01-01
    • 2023-03-23
    • 2022-01-18
    • 2021-10-15
    • 2014-02-22
    相关资源
    最近更新 更多