Amazon S3 REST API 403 error c#

后端 未结 2 1075
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-31 21:00

I\'m trying to get some code working to fetch a file from S3 using the REST API via C#. I\'ve seen other people doing similar things but for some reason I keep getting a 403

2条回答
  •  孤城傲影
    2020-12-31 21:24

    I don't know if this is the only problem, but it looks like a definite problem:

    + "x-amz-date:" + httpDate + "\n"
    

    x-amz-date is the header that supercedes the Date: header in the HTTP request itself, but in the string to sign, you just put the date, without "x-amz-date:" or anything in front of it, according to the examples:

    GET\n
    \n
    \n
    Tue, 27 Mar 2007 19:36:42 +0000\n
    /johnsmith/photos/puppy.jpg
    

    http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationRequestCanonicalization

    There is only one correct signature that can be generated for a request. S3 is going to generate that signature, and compare it to the one you sent, so there's not a single byte of room for error in the string-to-sign.

提交回复
热议问题