ssl - Implementing a Simple HTTPS Proxy Application with Java? -
i'm writing simple https proxy program java educational purposes. program listens on port (say 7443) incoming https requests browser (say firefox), parses request , forwards desired destination (say https://www.comodo.com).
firefox's proxy settings set use port ssl connections ( 127.0.0.1 : 7443 ).
my code short , simple:
static // initializer { system.setproperty("javax.net.ssl.keystore", "mykeystore"); system.setproperty("javax.net.ssl.keystorepassword", "password"); } sslserversocketfactory ssfactory = (sslserversocketfactory) sslserversocketfactory.getdefault(); try { sslserversocket listener = (sslserversocket) ssfactory.createserversocket(port, 64); listener.setuseclientmode(false); listener.setwantclientauth(false); listener.setneedclientauth(false); sslsocket connection = (sslsocket) listener.accept(); browser.starthandshake(); /* <<== exception throws @ line */ } catch (ioexception ex) { ex.printstacktrace(system.err); } but i'm catching following exception:
javax.net.ssl.sslexception: unrecognized ssl message, plaintext connection? the exception says connection plain-text, https connections firefox set use port. have logged firefox sending application this:
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 talking palin-text, , think connect socks command (i'm not sure though), haven't set in firefox's socks settings. below screenshot of firefox's proxy settings:

what missing here ?! need make work firefox or other browser ?!
------------------------------------------------------------------------------
for think duplicate of another question , has been answered in other 1 have say: yes, both questions have roots in similar problem answer in cited question directs @ using ssl sockets turned out misleading , resulted in new question. although aimed @ similar problem, question shows different , yet mislead path go solving problem , provide useful guidance future persons facing such problem.
get rid of ssl. process incoming connect command, make plaintext connection upstream server, , start copying bytes. browser , server speak ssl don't need @ all.
Comments
Post a Comment