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:
parent
3be09e4d67
commit
0651d89271
2 changed files with 4 additions and 5 deletions
|
@ -4,7 +4,6 @@ require 'cgi'
|
|||
require 'digest/md5'
|
||||
require 'excon'
|
||||
require 'formatador'
|
||||
require 'hmac-sha1'
|
||||
require 'hmac-sha2'
|
||||
require 'json'
|
||||
require 'mime/types'
|
||||
|
|
|
@ -124,7 +124,7 @@ 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)
|
||||
@digest = OpenSSL::Digest::Digest.new('sha1')
|
||||
@host = options[:host] || case options[:region]
|
||||
when 'ap-southeast-1'
|
||||
's3-ap-southeast-1.amazonaws.com'
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue