Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Custom Proxy server handling both http and https?

Ranch Hand
Posts: 55
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been trying for a while now to get a functional proxy going for http requests with no luck. I am currently using the http core Apache library as well as the http client to make it all work. Setting up the proxy to handle http was quite easy. However, as soon as I try to add anything that is coming from https the application fails. I think that part of my problem is that I'm still not entirely sure how the process is supposed to be handled. Initially, I was thinking that you set up a socket connection listen on port 8080 (or whatever port of your choosing) and as the browser sends the http requests the socket recognizes those requests are you as the programmer take those requests and making them and pass the response back to the browser. Problem is if my socket is a standard socket connection listening on port 8080 is handled fine. As soon as an https request comes in I received CONNECT request.once I see that connect request I change my clients on my proxy to send to the server via SSL and send back a response to the browser saying the handshake was complete. The problem is the next request that comes from the browser which I'm assuming is encrypted the socket closes. initially I thought that when I see the connect request I would change the socket to an SSL socket however what was happening then was if anything else from the browser came over the 8080 sslsocket was in clear text the SSL socket would throw a plaintext exception. So I'm thinking that the proxy server does not have to change the connection to SSL and simply just has to pass along the encrypted data to the server. Does this sound correct? Should I be able to simply create a standard connection on port 8080 and be able to handle both http and https?
If that is the case than though no cert will be needed between the browser and my proxy. However i think if the browser is sending https encrypted data its going to want to do a handshake and that cannot be done with standard socket. So needless to say im very confused!
Posts: 22024
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand correctly, you've written your own proxy that listens on only one port, right? Because of the encryption HTTPS provides, HTTP and HTTPS are different protocols, and should be handled by different ports. The defaults are 80 and 443 respectively, and Tomcat for one uses 8080 and 8443 by default.
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic