Paperclip + Fog + S3 +Digital Certificate

Hi!

I’m doing the following:

The user, through my app, is uploading his digital certificate to the S3 using Fog + Paperclip.

Until here I have no doubt in my process.

My problem begins when I need to use this certificate into the Rails. I found two ways of doing:

  1. Using the paperclip’s method #copy_to_local_file, saving it in a temporary file.

  2. Directly using Fog connection.

I thought both methods confused and I suspect there is a simpler way, because it seems an ordinary operation.

My question is: Is there a way of Paperclip give me this certificate like a File class instance without saving in temporary file?) sem eu ter que salvar na máquina local?

I’d like something like this:

person = Person.first

file = person.certificate.to_file # It would be great if this method exists!!!

OpenSSL::PKCS12.new(file, certificate_password)

PS 1: the certificates are privates in S3. So, any suggestion using certificate.url is invalid, because the file wouldn’t be accessible.

Ps 2: I don’t know if my workflow is right.

Thank you