I am writing a simple HTTPS proxy program with Java for educational purposes. My program listens on the port (say 7443 ) for incoming HTTPS requests from the browser (say Firefox ), analyzes the request and redirects it to the desired destination (say https://www.comodo.com ).
Firefox proxy settings are configured to use my port for SSL connections ( 127.0.0.1 : 7443 ).
My code is short and simple:
static
But I caught the following exception:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
An exception indicates that the connection may be plain text, but only HTTPS connections from Firefox are configured to use this port. I registered that Firefox sends to my application which:
CONNECT www.comodo.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0 Proxy-Connection: keep-alive Connection: keep-alive Host: www.comodo.com
Firefox says the palin text, and I think CONNECT is a SOCKS command (I'm not sure though), where I did not set anything in Firefox SOCKS settings. Below is a screenshot of the Firefox proxy settings:

What am I missing here ?! What do I need to do to make this work with Firefox or any other browser ?!
----------------------------------------------- --- ----------------------------
For those who think that this is a duplicate of another question , and that they answered it in another, I must say: "Yes, both questions have roots in a similar problem, but the only answer in the quoted question is sent when using SSL sockets, which turned out to be deceptive and led to this new question.Therefore, although they are aimed at a similar problem, this question shows a completely different and yet misleading way to solve the problem, and therefore it can serve as a useful guide for future individuals facing Second problem.