Skip to main content

creating a Java Proxy Server that accepts HTTPS



i already have a working HTTP proxy server that can handle multiple HTTP request. now my problem is how do I handle https request?





here's a simplified code i am using:







class Daemon

{

public static void main(String[] args)

{

ServerSocket cDaemonSocket = new ServerSocket(3128);



while(true)

{

try

{

Socket ClientSocket = cDaemonSocket.accept();

(new ClientHandler(ClientSocket )).start();

}catch(Exception e) { }

}

}



}







and the ClientHandler







class ClientHandler extends Thread

{

private Socket socket = null;

private Socket remoteSocket = null;

private HTTPReqHeader request = null;

ClientHandler(Socket socket)

{

this.socket = socket;

request = new HTTPReqHeader();

request.parse(socket); // I read and parse the HTTP request here

}



public void run()

{

if(!request.isSecure() )

{

remoteSocket = new Socket(request.url,request.port);

}

else

{

// now what should I do to established a secured socket?

}



// start connecting remoteSocket and clientSocket

...........

}

}







}





I really did try searching how, I have encounter SSL tunneling, certificate,handshaking, SSLSocket, SSLFactory, trustStore and etc. something like that but still could not make it work.. I just need to know what are the things I need and the steps to established a connection to a SSL-enabled web server.


Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?