I am using 2 proxies to intercept the communication between my phone and my server. Here is my topology:
phone --> proxy 1 --> proxy 2 --> server
proxy1 is listening to port 8080, proxy 2 is listening to port 8080 but I redirect all what it gets to ports 80 and 443, finally my server is listening to port 443.
phone's IP address :
proxy2's IP address:
server's IP address:
All the devices I am using are in my LAN.
The first proxy is installed on my phone (Android) and it enables me to route all the traffic coming from my phone to the second proxy (when I use the second proxy on its own, it doesn't intercept all the traffic, that's because some applications choose to communicate directly with the server without passing by the proxy even though my phone is rooted).
I use Wireshark to visualize the communication between my phone and the server on the second proxy which is mitmproxy, I've installed the certificate on my phone, and here is what I get:
192.168.10.199 192.168.10.246 POST /message HTTP/1.1
192.168.10.199 is the IP address of my phone and 192.168.10.246 is the IP address of proxy 2, so proxy 2 is receiving the information from my phone, but when it tries to transmit to the server, here is what I get:
192.168.10.246 192.168.10.199 HTTP/1.1 502 Bad Gateway (text/html), Alert (Level: Warning, Description: Close Notify)
Here is exactly the message I get on Wireshark:
<html> <head> <title>502 Bad Gateway</title> </head> <body> <h1>502 Bad Gateway</h1> <p>TlsProtocolException("Cannot establish TLS with 192.168.10.211:443 (sni: None): TlsException('Cannot validate certificate hostname without SNI',)",)</p> </body> </html>
I tried running the same request
POST https://192.168.10.211:443/message on Postman and the message I get is not the same:
Could not get any response There was an error connecting to https://192.168.10.211:443/message.
Why this might have happened:
The server couldn't send a response:
Ensure that the backend is working properly Self-signed SSL certificates are being blocked:
Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly
Ensure that proxy is configured correctly in Settings > Proxy
Change request timeout in Settings > General
I am trying to understand what's exactly happening? My guess is the certificate must be installed on the first proxy (which is installed on my phone) not on the phone itself and that's why I get the exception above. Am I right?