This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Custom Proxy server handling both http and https?

 
Ranch Hand
Posts: 55
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 22511
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic