2

I need to show a private file from S3, so i am generating S3 sign URL, but when I open url in the browser i get this,

<Error>
<Code>AccessDenied</Code>
<Message>Request is not yet valid</Message>
<X-Amz-Date>1559667828000</X-Amz-Date>
<Expires>2019-06-04T17:08:46Z</Expires>
<ServerTime>2019-06-04T04:38:30Z</ServerTime>
<RequestId>BCB52dF0973D5E20</RequestId>
<HostId>********************************************</HostId>
</Error>

I do not understand what is the problem, can anyone explain this error.

Code for generating signed url

 GetPreSignedUrlRequest request1 = new GetPreSignedUrlRequest
    {
      BucketName = bucketName,
      Key = "key",
      Expires = DateTime.Now.AddMinutes(5)
    };
   urlString = client.GetPreSignedURL(request1);
Amol B Jamkar
  • 1,227
  • 10
  • 19

1 Answers1

10

I think your local pc timezone is not correct.

Your local pc should have same date time zone as per region of bucket for which you are generating signed url.

komal kosbatwar
  • 161
  • 2
  • 7
  • Thanks for saving my day. I have corrected time zone of my PC and now its working :) – Amol B Jamkar Jun 05 '19 at 16:05
  • In my case the problem was that I was running a MinIO in a Docker container on Windows using the WSL 2 backend. The WSL clock was hanging behind the system clock after I put my laptop to sleep - only a restart of Windows helped. – Moritz Jun 01 '21 at 11:12
  • Moritz's comment explains my situation as well. Luckily, I recently came across a solution that doesn't require a Windows restart. `docker run --rm --privileged alpine hwclock -s` Source: https://stackoverflow.com/a/55245963/5984310 – Colt Bauman Mar 09 '22 at 10:47