プロジェクトでの画像操作に Dragonfly (https://github.com/markevans/dragonfly) を使用しており、データ ストレージ エンジンとしてフォグを使用しています。最近、リクエストで奇妙な Amazon エラーが発生し始めました。主なエラーは次のとおりです。
AWS authentication requires a valid Date or x-amz-date header
と
The difference between the request time and the current time is too large.
これは、1 つの開発マシンだけで、他のすべてのマシンで正常に動作します。Ruby 1.9およびRails 3.0.10でMac OSXを実行しているため、タイムスタンプはマシン上で問題ありません。何らかの理由でヘッダーがエポック時間として入っているようです...
完全なエラー:
Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden)
request => {:connect_timeout=>60,
:headers=>{"Date"=>"Wed, 31 Dec 1969 23:59:59 +0000", "Authorization"=>"AWS AUTHKEY", "Host"=>"my-development.s3.amazonaws.com:443"}, :instrumentor_name=>"excon", :mock=>false, :nonblock=>true, :read_timeout=>60, :retry_limit=>4, :ssl_ca_file=>"/Users/temp/.rvm/gems/ruby-1.9.2-p180/gems/excon-0.16.2/data/cacert.pem", :ssl_verify_peer=>true, :write_timeout=>60, :host=>"my-development.s3.amazonaws.com", :path=>"/", :port=>"443", :query=>{}, :scheme=>"https", :expects=>200, :idempotent=>true, :method=>"GET", :response_block=>#<Proc:0x007fe4c3cc51f0@/Users/temp/.rvm/gems/ruby-1.9.2-p180/gems/fog-1.5.0/lib/fog/core/connection.rb:16 (lambda)>}
response => #<Excon::Response:0x007fe4c3c77a18 @body="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>AWS authentication requires a valid Date or x-amz-date header</Message><RequestId>AF3S5E9BAA514F1</RequestId><HostId>SOMETHING</HostId></Error>", @headers={"x-amz-request-id"=>"AF3S5E9BAA514F1", "x-amz-id-2"=>"SOMETHING", "Content-Type"=>"application/xml", "Transfer-Encoding"=>"chunked", "Date"=>"Thu, 25 Oct 2012 19:03:39 GMT", "Server"=>"AmazonS3"}, @status=403>):
ERROR Excon::Errors::Forbidden: Expected([200, 206]) <=> Actual(403 Forbidden) request => {:connect_timeout=>60,
:headers=>{"Date"=>"Thu, 01 Jan 1970 00:00:01 +0000", "Authorization"=>"AWS AUTHKEY", "Host"=>"my-development.s3.amazonaws.com:443"}, :instrumentor_name=>"excon", :mock=>false, :nonblock=>true, :read_timeout=>60, :retry_limit=>4, :ssl_ca_file=>"/Users/temp/.rvm/gems/ruby-1.9.2-p180/gems/excon-0.16.2/data/cacert.pem", :ssl_verify_peer=>true, :write_timeout=>60, :host=>"my-development.s3.amazonaws.com", :path=>"/2012%2F10%2F18%2F19%2F32%2F28%2F836%2Fdragonfly20121018_47202_2lm4t0", :port=>"443", :query=>nil, :scheme=>"https", :expects=>[200, 206], :idempotent=>true, :method=>"GET"} response =>
#<Excon::Response:0x007fd11e048ea8 @body="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>RequestTimeTooSkewed</Code><Message>The difference between the request time and the current time is too large.</Message><MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds><RequestId>85D12B885D8B4DBE</RequestId><HostId></HostId><RequestTime>Thu, 01 Jan 1970 00:00:01
+0000</RequestTime><ServerTime>2012-10-26T21:19:18Z</ServerTime></Error>", @headers={"x-amz-request-id"=>"85D12B885D8B4DBE", "x-amz-id-2"=>"SOMETHING", "Content-Type"=>"application/xml", "Transfer-Encoding"=>"chunked", "Date"=>"Fri, 26 Oct 2012 21:19:16 GMT", "Server"=>"AmazonS3"}, @status=403>