Ny way to cache HTTPS requests in a proxy server

httpsPROXYsquid

We are using Squid proxy server in our environment and we want to cache HTTPS requests.

Is there any way to configure Squid or in general a proxy server to cache HTTPS requests?

Best Answer

There is a way to do it, but it's fundamentally against the reasons for using HTTPS.

Here's how you'd do it.

  1. Generate a self-signed SSL Certificate for the site you'd like to intercept and cache the requests from.
  2. Install and run stunnel on your proxy server, telling it that the certificate it should present is the one generated in stage 1.
  3. Have stunnel forward the decrypted requests to squid.
  4. You might need to have stunnel on the other side, or openssl_client to re-encrypt the request to the upstream server.

Caveats:

  1. Your users will hate you. Every SSL request to that site will present an invalid certificate window.
  2. You're exposing yourself to potential lawsuits for doing naughty things. (IANAL)
  3. You'll only ever be able to get a self-signed certificate working for this, because of how the PKI web of trust for SSL Certificates is supposed to work. Saying nothing about compromised root CAs.

I'm not going to give you the exact details of how to do this, because a) I think it's somewhat unethical, and b) It's better for you to learn how to do it.

I suggest you research how stunnel and man-in-the-middle attacks work.