From 50b0dcbe73a5acb85aad5985b97b20654309e14c Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Fri, 25 Jan 2013 11:24:47 -0500 Subject: [PATCH] [HP|storage] Fix generate_object_temp_url to use signer that is backward compatible to 1.8.7 --- lib/fog/hp/storage.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fog/hp/storage.rb b/lib/fog/hp/storage.rb index 7ace87205..b42466500 100644 --- a/lib/fog/hp/storage.rb +++ b/lib/fog/hp/storage.rb @@ -167,7 +167,11 @@ module Fog encoded_path = "#{path}/#{Fog::HP.escape(container)}/#{Fog::HP.escape(object)}" string_to_sign = "#{method}\n#{expires}\n#{sig_path}" - signed_string = Digest::HMAC.hexdigest(string_to_sign, @hp_secret_key, Digest::SHA1) + # Only works with 1.9+ Not compatible with 1.8.7 + #signed_string = Digest::HMAC.hexdigest(string_to_sign, @hp_secret_key, Digest::SHA1) + # Compatible with 1.8.7 onwards + hmac = OpenSSL::HMAC.new(@hp_secret_key, OpenSSL::Digest::SHA1.new) + signed_string = hmac.update(string_to_sign).hexdigest signature = @hp_tenant_id.to_s + ":" + @hp_access_key.to_s + ":" + signed_string signature = Fog::HP.escape(signature)