1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

use OpenSSL for SHA1 HMAC

This commit is contained in:
geemus 2010-06-15 20:28:18 -07:00
parent 3be09e4d67
commit 0651d89271
2 changed files with 4 additions and 5 deletions

View file

@ -4,7 +4,6 @@ require 'cgi'
require 'digest/md5'
require 'excon'
require 'formatador'
require 'hmac-sha1'
require 'hmac-sha2'
require 'json'
require 'mime/types'

View file

@ -124,8 +124,8 @@ module Fog
def initialize(options={})
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = HMAC::SHA1.new(@aws_secret_access_key)
@host = options[:host] || case options[:region]
@digest = OpenSSL::Digest::Digest.new('sha1')
@host = options[:host] || case options[:region]
when 'ap-southeast-1'
's3-ap-southeast-1.amazonaws.com'
when 'us-west-1'
@ -200,8 +200,8 @@ DATA
canonical_resource.chop!
string_to_sign << "#{canonical_resource}"
hmac = @hmac.update(string_to_sign)
signature = Base64.encode64(hmac.digest).chomp!
signed_string = OpenSSL::HMAC.digest(@digest, @aws_secret_access_key, string_to_sign)
signature = Base64.encode64(signed_string).chomp!
end
end
end