Impersonate a server

98 views Asked by At

Here is my probelm: I have an Android application that communicates with an API on a specific server, which has the IP address IP_Server, through HTTP messages and using SSL. I want to impersonate the API and receive the messages from the application (from one of my smartphone) on my computer and respond to them as I want (according to the API protocol). To do so, in my router, I redirect the route for the IP_Server to my local network and I assign the IP_Server IP address to my computer. Then, I run a Java Server that listens on the port 443 using SSLSocket. At this stage, I receive the connection request when the application wants to communicate. However, the handshake fails. I think that it’s a certificate problem but I’m not sure and I don’t know how to resolve this issue.

public static void startServer() throws Exception
{
   SSLServerSocketFactory sslserversocketfactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
   SSLServerSocket sslserversocket = (SSLServerSocket) sslserversocketfactory.createServerSocket(443);

   while (running)
   {
       // Listen.
       SSLSocket clientSocket = (SSLSocket)sslserversocket.accept();

       System.out.println("Connection accepted from:" +
                           clientSocket.toString());

       clientSocket.startHandshake(); // This line causes a timeout.

       // Handle the request.
       threadPool.execute(new ServerThread(clientSocket));
   }
}

Thanks for your help!

0

There are 0 answers