I am wondering if there is a practical way to establish a secure, encrypted network connection through an MITM proxy given the ability to communicate secrets out-of-band with a second, external proxy. Let’s say the MITM is part of a corporate firewall, a filtering ISP, or it’s set up by a dictatorial government.
If the only way to establish an initial connection is by accepting the certificate presented by the MITM, then the proxy can monitor the contents of the entire exchange. This question suggests:
Clearly SSL-over-SSL-over-SSL-...-over-SSL works most of the time for corporate firewalls and the like, but it relies on security by obscurity and the handshake would take forever.
I understand why the handshake would take a long time, but I don’t understand why it ‘works.’ If the MITM can read the traffic, would it not intercept nested certificate and key exchange as well?
But let’s assume that I can set up a trusted proxy outside, on the other side of the MITM, with a preshared key. Is there an easy way to establish an encrypted tunnel through the untrusted connection? I am imagining that by using a symmetric cipher I could skip the certificate check and key exchange, which the MITM would catch, and just start transmitting encrypted data. Then through this second tunnel, I could establish a trusted connection, ideally SSH.
I imagine that a determined MITM could potentially deduce the encryption scheme and key by observing the traffic over a long period of time, but I am not concerned about such a drawback. The ability to do this would be useful on a short-term basis, and the ability to rotate the preshared key out-of-band would allow somewhat longer-term use.
I’m interested in a practical, immediate solution. Is this feasible? Is there existing software (preferably OSS for linux) that does this? If not, is there a library that would make such a solution easy to build?