From fc29620996a0c0791b362f3113066ac9e6f38d42 Mon Sep 17 00:00:00 2001 From: Jon K Hellan Date: Mon, 1 Dec 2014 09:39:54 +0100 Subject: [PATCH] Use old style date header for signature v2 --- lib/fog/aws/storage.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/fog/aws/storage.rb b/lib/fog/aws/storage.rb index a18f38aa0..23f19fb02 100644 --- a/lib/fog/aws/storage.rb +++ b/lib/fog/aws/storage.rb @@ -488,10 +488,11 @@ module Fog params[:headers] = (params[:headers] || {}).dup params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token - params[:headers]['x-amz-date'] = date.to_iso8601_basic if @signature_version == 2 - params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature_v2(params)}" + expires = date.to_date_header + params[:headers]['Date'] = expires + params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature_v2(params, expires)}" end params = request_params(params) @@ -502,6 +503,7 @@ module Fog if @signature_version == 4 + params[:headers]['x-amz-date'] = date.to_iso8601_basic if params[:body].respond_to?(:read) # See http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html params[:headers]['x-amz-content-sha256'] = 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD' @@ -623,7 +625,7 @@ DATA end end - def signature_v2(params) + def signature_v2(params, expires) headers = params[:headers] || {} string_to_sign = @@ -631,7 +633,7 @@ DATA #{params[:method].to_s.upcase} #{headers['Content-MD5']} #{headers['Content-Type']} - +#{expires} DATA amz_headers, canonical_amz_headers = {}, ''