I'm making a Proxy server and I have a problem with the SSL tunneling. This is the secuence I use:
1. Read de socket information from the client
2. If I receive a CONNECT servername:443 HTTP/1.0... then
3. I open a secure conection with the server using the Microsoft's SslStream for .Net
4. If the conection is stablished then
5. I send a HTTP/1.0 200 Conection established... to then client
6. I read data from the client socket and send without any translation to the server.
7. I read data from the server and send the data without any translation to the client.
8. I loop to point 6 until the connection is closed.
The problem is in point 6. After I send the "Conection established" to the client it return a secuence of binary data. I send this information to the server and the server return an "Bad request" or similars errors, depending on the ssl server that I connect.
I think that the problem wil be that the client socket is an standard Socket object and the server socket is an SslStream object.