首页 > 解决方案 > 即使使用正确的键,S3 boto 连接也会导致 ClientError

问题描述

我正在运行一个命令:

aws s3 cp s3://full-key .

我已确保两台 pc 上的键相同,但是,一台 pc 能够访问该对象,而另一台收到错误:

/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:354: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  SNIMissingWarning
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden

需要注意的是,我的实例的时区是 UTC 命令:

timedatectl status                   
      Local time: Fri 2019-01-04 09:04:39 UTC
  Universal time: Fri 2019-01-04 09:04:39 UTC
        Timezone: Etc/UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

但是当我输入时,date我得到Fri Jan 4 09:05:44 UTC 2019 但是,谷歌将 utc 时间显示为:8:52 am Friday, 4 January 2019 Coordinated Universal Time (UTC)

标签: pythonamazon-web-servicesamazon-s3botobotocore

解决方案


我注意到我的 ec2 实例上的奇怪时间设置。虽然设置是 UTC,但时间不是。当我尝试列出存储桶中的所有目录时,我遇到了一个错误:too much time difference resulting into timeout. 因此,我手动将实例的时间更改为实际的 UTC 时间并再次尝试,然后可以访问存储桶。

为什么我要尝试时间设置?我在某处读到时间可能是这里的一个问题。


推荐阅读