Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Encrypt files on server and then decrypt when user downloads

by moritz (Cardinal)
on Oct 19, 2012 at 19:03 UTC ( #1000020=note: print w/ replies, xml ) Need Help??


in reply to Encrypt files on server and then decrypt when user downloads

Simply configure your web server to use SSL. Then the files (and indeed the whole HTTP response) are encrypted on the server, and decrypted automatically on the client side.

Even better, you don't have to deal with encryption in your own code (which is always a hairy subject to get right), and your users don't have to mess with manually decrypting files. Big win for everybody, I'd say.


Comment on Re: Encrypt files on server and then decrypt when user downloads
Re^2: Encrypt files on server and then decrypt when user downloads
by blue_cowdawg (Prior) on Oct 19, 2012 at 19:13 UTC
        Simply configure your web server to use SSL.

    I wasn't going to suggest that, however you are very correct. Reason I wasn't going to suggest that is depending on his web environment it may not be an option. For instance hosting companies usually (well... that is less true these days) charge a premium for SSL enabled hosting. In a corporate environment SSL usually incurs a cost that some management won't approve.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
      For instance hosting companies usually (well... that is less true these days) charge a premium for SSL enabled hosting. In a corporate environment SSL usually incurs a cost that some management won't approve.

      That might be true, but I don't think one can expect to come up with a self-made solution that comes near to SSL in terms of security, and that doesn't cost much more in total, if you include cost for development and maintenance of the custom solution.

Re^2: Encrypt files on server and then decrypt when user downloads
by MPM (Novice) on Oct 19, 2012 at 19:27 UTC

    SSL is being used. However, I'm looking to protect against the situation where someone gets on the server. I don't want them to be able to view the files directly on the machine or be able to copy them to another machine and then view them. So I'm more looking to protect the files, not protect the data on the files while they are downloading them. Thanks for the response though.

      oh, and just to add, I thought maybe gpg but I'm not sure how that would be done and I'm not sure if that would be the best solution

      I'm looking to protect against the situation where someone gets on the server. I don't want them to be able to view the files directly on the machine or be able to copy them to another machine and then view them.

      If you are going to decrypt them during download, and the bad guys have access to the server, they would only need to inspect your download script to see how to decrypt the files.

      If they can copy the encrypted file, they can also copy the decryption script and perform the decryption on their own machine at their leisure.

      The only way to protect the files on a compromised server would be for the users to download them encrypted and decrypt them locally using local software and keys known only to themselves. For example, if you encrypted the files for each user using their public key, and they decrypt them locally using their private key.

      The downside of that is that you would have to encrypt files that may be downloaded by multiple users, multiple times, and keep multiple, unique copies of them.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      RIP Neil Armstrong

        I understand that it's not 100% secure, I'm just trying to add another layer, well it's not really me that wants to add it, but anyway.....also, just because they have access to the server and possibly the files, that wouldn't necessarily mean they have access to the script also. Thanks for the input though.

        If the files are encrypted with a user-supplied password/passphrase/public key, and decrypted by the server on download, it would give a fairly good balance between security and convenience.

        The attackers, if they get control of the server, could then only decrypt the files the users download by sniffing passphrases.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000020]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2014-07-28 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls