Is it possible to have HTTPS connections over proxy servers? If yes, what kind of proxy server allows this?
Duplicated with How to use Socks 5 proxy with Apache HTTP Client 4?
Is it possible to have HTTPS connections over proxy servers? If yes, what kind of proxy server allows this?
Duplicated with How to use Socks 5 proxy with Apache HTTP Client 4?
Here is my complete Java code that supports both HTTP and HTTPS requests using SOCKS proxy.
The short answer is: It is possible, and can be done with either a special HTTP proxy or a SOCKS proxy.
First and foremost, HTTPS uses SSL/TLS which by design ensures end-to-end security by establishing a secure communication channel over an insecure one. If the HTTP proxy is able to see the contents, then it's a man-in-the-middle eavesdropper and this defeats the goal of SSL/TLS. So there must be some tricks being played if we want to proxy through a plain HTTP proxy.
The trick is, we turn an HTTP proxy into a TCP proxy with a special command named
CONNECT
. Not all HTTP proxies support this feature but many do now. The TCP proxy cannot see the HTTP content being transferred in clear text, but that doesn't affect its ability to forward packets back and forth. In this way, client and server can communicate with each other with help of the proxy. This is the secure way of proxying HTTPS data.There is also an insecure way of doing so, in which the HTTP proxy becomes a man-in-the-middle. It receives the client-initiated connection, and then initiate another connection to the real server. In a well implemented SSL/TLS, the client will be notified that the proxy is not the real server. So the client has to trust the proxy by ignoring the warning for things to work. After that, the proxy simply decrypts data from one connection, reencrypts and feeds it into the other.
Finally, we can certainly proxy HTTPS through a SOCKS proxy, because the SOCKS proxy works at a lower level. You may think a SOCKS proxy as both a TCP and a UDP proxy.
I had tried
ssh -N -D 12345 login@proxy_server
localhost:12345
but this resulted in the error "Insecure connection" whenever I tried to connect to an https website.
The solution was to
Reference from digital ocean documentation
How To Route Web Traffic Securely Without a VPN Using a SOCKS Tunnel
tunneling HTTPS through SSH (linux version):
everything you do on localhost. then:
I don't think "have HTTPS connections over proxy servers" means the Man-in-the-Middle attack type of proxy server. I think it's asking whether one can connect to a http proxy server over TLS. And the answer is yes.
Yes, see my question and answer here. HTTPs proxy server only works in SwitchOmega
The kind of proxy server deploys SSL certificates, like how ordinary websites do. But you need a
pac
file for the brower to configure proxy connection over SSL.You can accomplish this using man-in-the-middle techniques with dynamic SSL generation. Take a look at mitmproxy - it's a Python based, SSL-capable MITM proxy.