Encrypt / Decrypt files using Carrierwave and save to S3 (Rails)

I need to be able to encrypt files before saving them to S3, and then decrypt them when accessing them. Files will be images, documents, PDF, etc.

I use Carrierwave to handle loading and storing files (this is with Ruby on Rails). I store them in Amazon S3.

Has anyone done this, or have any idea how this will be achieved?

Thanks.

+4
source share
3 answers

Amazon has now released features that automatically encrypt / decrypt files on S3. The need to do this by itself no longer exists. Details here http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?UsingEncryption.html

+4
source

To handle encryption, you should study processor implementation. If you use any other processors, you may have to look for an extension of the Carrierwave harness and the addition of a processor sequencing mechanism so you can be sure that encryption is the last.

For decryption, you can either override the existing accessor to make the decryption transparent, or add a new method that returns the decrypted file and use this instead of the accessor. The latter approach is probably more resistant to upstream changes.

+3
source

I know this post is a few months old, but if you are still looking for answers, look at what I wrote in the carrierwave_securefile journal. It is still a newbie and probably a bit buggy on other settings, but uses Crypt19 to encrypt Blowfish in files before downloading.

http://github.com/dougc84/carrierwave_securefile

+2
source

All Articles