Search code examples
javasocketssslproxyjsse

Browser don't receive data from proxy java


I'm trying to do a java proxy, the http part work fine, but i have a problem with SSL part. I get the connect request, then i create a socket to connect to the website and i can get html code (if i write it in a file and launch this file with chrome, i have my page) but i try to write on the outputstream of my first socket and the browser don't receve data.

I tried to upgrade the socket in SSLSocket but it doesn't work and when i try to do an handshake, it fail with an unknown message error. Before create the SSLSocket, i created the keystore and it work (i tested it)

When i try to connect to the proxy, firefox give me this error : ssl_error_rx_record_too_long


Solution

  • An HTTP proxy doesn't have to use SSL at all. It receives the CONNECT request in plaintext, then it connects to the target and sends a response to the client, then from there on it just exchanges bytes.