Browse files

Avoids Digest::HMAC.hexdigest to remain 1.8.7 compatibility

  • Loading branch information...
1 parent 99b1ae0 commit 36c13796ad9c1c1c4127def7ee8220b379e77e8f @enterprise-rails enterprise-rails committed Jun 26, 2013
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/fog/hp/storage.rb
View
6 lib/fog/hp/storage.rb
@@ -175,16 +175,16 @@ def generate_object_temp_url(container, object, expires_secs, method)
# As the HP provider is broadly used by OpenStack users the OpenStack strategy is applied when
# the @hp_account_meta_key is given.
if @hp_account_meta_key then
- puts "\n\nUsing account meta key #{@hp_account_meta_key}\n\n"
- hmac_body = "#{method}\n#{expires}\n#{encoded_path}"
- signature = Digest::HMAC.hexdigest(hmac_body, @hp_account_meta_key, Digest::SHA1)
+ hmac = OpenSSL::HMAC.new(@hp_account_meta_key, OpenSSL::Digest::SHA1.new)
+ signature = hmac.update(string_to_sign).hexdigest
else
# 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)
end

0 comments on commit 36c1379

Please sign in to comment.