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

fall back to ruby-hmac when openssl refuses to sha256

This commit is contained in:
geemus 2010-06-15 21:19:40 -07:00
parent 54ba56ac7f
commit 7aec7febb3
4 changed files with 30 additions and 9 deletions

View file

@ -8,5 +8,6 @@ gem 'mime-types', ">= 0"
gem 'net-ssh', ">= 0"
gem 'nokogiri', ">= 0"
gem 'rspec', '>= 0'
gem 'ruby-hmac', '>= 0'
gem 'shindo', '>= 0.1.5'
gem 'builder', '>= 0'

View file

@ -20,9 +20,11 @@ specs:
version: 1.4.2
- rspec:
version: 1.3.0
- ruby-hmac:
version: 0.4.0
- shindo:
version: 0.1.5
hash: 58a08d793d993ef27b7140767d8a94aa21a49a13
hash: 12012795f07111bf764cef89d9ba91f521c54956
sources:
- Rubygems:
uri: http://gemcutter.org
@ -35,11 +37,15 @@ dependencies:
version: ">= 0"
group:
- :default
rake:
version: ">= 0"
group:
- :default
rspec:
version: ">= 0"
group:
- :default
rake:
ruby-hmac:
version: ">= 0"
group:
- :default
@ -51,14 +57,14 @@ dependencies:
version: ">= 0"
group:
- :default
json:
version: ">= 0"
group:
- :default
excon:
version: ">= 0.0.26"
group:
- :default
json:
version: ">= 0"
group:
- :default
builder:
version: ">= 0"
group:

View file

@ -48,6 +48,7 @@ Gem::Specification.new do |s|
s.add_dependency('mime-types')
s.add_dependency('net-ssh')
s.add_dependency('nokogiri')
s.add_dependency('ruby-hmac')
## List your development dependencies here. Development dependencies are
## those that are only needed during development

View file

@ -25,9 +25,22 @@ module Fog
end
def setup_sha256
@digest = OpenSSL::Digest::Digest.new('sha256')
@signer = lambda do |data|
OpenSSL::HMAC.digest(@digest, @key, data)
begin
@digest = OpenSSL::Digest::Digest.new('sha256')
@signer = lambda do |data|
OpenSSL::HMAC.digest(@digest, @key, data)
end
rescue RuntimeError => error
unless error.message == 'Unsupported digest algorithm (sha256).'
raise error
else
require 'hmac-sha2'
@hmac = ::HMAC::SHA256.new(@key)
@signer = lambda do |data|
@hmac.update(data)
@hmac.digest
end
end
end
end