dwilkie / carrierwave_direct

Process your uploads in the background by uploading directly to S3
MIT License
839 stars 181 forks source link

does not work as expected with AWS - SignatureDoesNotMatch #218

Closed martynasp closed 6 years ago

martynasp commented 6 years ago

If we have such uploader:

class FileUploader < CarrierWave::Uploader::Base
  include CarrierWaveDirect::Uploader
end

AWS responds with:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAJ3XAFXRG7WWCP36Q</AWSAccessKeyId><StringToSign>...</StringToSignBytes><RequestId>89A2E7E7BD6135A9</RequestId><HostId>ClcOGqdr9Xx+r7lgzlmmCYsFKiMVu0G/kJhFan2+c4va+1zbx27EcGsbEztPg6qrO2EWBzYDJHQ=</HostId></Error>
martynasp commented 6 years ago

Reverting back (from v.0.0.15) in Uploader module to this implementation:

def signature
      Base64.encode64(
        OpenSSL::HMAC.digest(
          OpenSSL::Digest.new('sha1'),
          aws_secret_access_key, policy
        )
      ).gsub("\n","")
    end

solves the issue