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 'digest/md5'
|
||||||
require 'excon'
|
require 'excon'
|
||||||
require 'formatador'
|
require 'formatador'
|
||||||
require 'hmac-sha1'
|
|
||||||
require 'hmac-sha2'
|
require 'hmac-sha2'
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'mime/types'
|
require 'mime/types'
|
||||||
|
|
|
@ -124,8 +124,8 @@ module Fog
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
@aws_access_key_id = options[:aws_access_key_id]
|
@aws_access_key_id = options[:aws_access_key_id]
|
||||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
@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]
|
@host = options[:host] || case options[:region]
|
||||||
when 'ap-southeast-1'
|
when 'ap-southeast-1'
|
||||||
's3-ap-southeast-1.amazonaws.com'
|
's3-ap-southeast-1.amazonaws.com'
|
||||||
when 'us-west-1'
|
when 'us-west-1'
|
||||||
|
@ -200,8 +200,8 @@ DATA
|
||||||
canonical_resource.chop!
|
canonical_resource.chop!
|
||||||
string_to_sign << "#{canonical_resource}"
|
string_to_sign << "#{canonical_resource}"
|
||||||
|
|
||||||
hmac = @hmac.update(string_to_sign)
|
signed_string = OpenSSL::HMAC.digest(@digest, @aws_secret_access_key, string_to_sign)
|
||||||
signature = Base64.encode64(hmac.digest).chomp!
|
signature = Base64.encode64(signed_string).chomp!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue