From 1fca8626bc17dfc35a3021e7ff22a04e3cd4806c Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 1 May 2014 16:30:12 +0200 Subject: [PATCH] Use OpenSSL::Digest where possible. Per #525 it appears that the regular Digest module is not thread-safe. Testing showed that OpenSSL::Digest on the other hand is working fine. Currently the SQS related code still uses Digest in one place. I tried replacing that but this triggered spec failures for unknown reasons. The OpenSSL::Digest API should be identical to Digest so I'm not really sure what's going on here. --- lib/aws/core/signers/version_4.rb | 2 +- lib/aws/core/signers/version_4/chunk_signed_stream.rb | 2 +- lib/aws/s3/client.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/aws/core/signers/version_4.rb b/lib/aws/core/signers/version_4.rb index fc7c2e9474a..80e9924ec4a 100644 --- a/lib/aws/core/signers/version_4.rb +++ b/lib/aws/core/signers/version_4.rb @@ -192,7 +192,7 @@ def body_digest req, chunk_signing # @param [String] value # @return [String] def hexdigest value - digest = Digest::SHA256.new + digest = OpenSSL::Digest::SHA256.new if value.respond_to?(:read) chunk = nil chunk_size = 1024 * 1024 # 1 megabyte diff --git a/lib/aws/core/signers/version_4/chunk_signed_stream.rb b/lib/aws/core/signers/version_4/chunk_signed_stream.rb index 5da0f3a30be..087e7dc427a 100644 --- a/lib/aws/core/signers/version_4/chunk_signed_stream.rb +++ b/lib/aws/core/signers/version_4/chunk_signed_stream.rb @@ -150,7 +150,7 @@ def sign value end def hash value - Digest::SHA256.new.update(value).hexdigest + OpenSSL::Digest::SHA256.new.update(value).hexdigest end class << self diff --git a/lib/aws/s3/client.rb b/lib/aws/s3/client.rb index 637fc650af9..28d82dd5b64 100644 --- a/lib/aws/s3/client.rb +++ b/lib/aws/s3/client.rb @@ -236,7 +236,7 @@ def is_xml? possible_xml end def md5 str - Base64.encode64(Digest::MD5.digest(str)).strip + Base64.encode64(OpenSSL::Digest::MD5.digest(str)).strip end def parse_copy_part_response resp @@ -1015,7 +1015,7 @@ def self.object_method(method_name, verb, *args, &block) # * `:permission` - (String) Logging permissions given to the Grantee # for the bucket. The bucket owner is automatically granted FULL_CONTROL # to all logs delivered to the bucket. This optional element enables - # you grant access to others. Valid Values: FULL_CONTROL | READ | WRITE + # you grant access to others. Valid Values: FULL_CONTROL | READ | WRITE # @return [Core::Response] bucket_method(:put_bucket_logging, :put) do configure_request do |req, options| @@ -1062,7 +1062,7 @@ def self.object_method(method_name, verb, *args, &block) xml = xml.doc.root.to_xml req.body = xml req.headers['content-md5'] = md5(xml) - + super(req, options) end