Tomcat Http and Https on the same port

I have a web service endpoint and an http connector on port X. At some point, this endpoint needs to switch to https, but on the same port! (I know this is not an ordinary way to do something, but this is what my clients expect from the old server that they use ...)

Is there any way to do this in tomcat?

+4
source share
4 answers

This is not possible for Tomcat. The HTTPS connector will only accept SSL connections.

We have such a proxy server developed in-house. This is not so difficult to do. You just need to check the first incoming packet. Search for an SSL confirmation template. We are only looking for CLIENT_HELLO. Once you figure out the protocol, you can redirect the request accordingly.

This is really ugly. You should not do this if possible. We must do this because legacy clients do this and it is not possible to update them all.

+5
source

There is such a thing as updating HTTPS, in which case the plaintext HTTP connection is updated to HTTP by mutual agreement after it is created. Is that what you mean? If so, Tomcat doesn't seem to support it out of the box, and Java doesn't work either. You can probably write yourself a Tomcat Connector that will do this; on the client side you have a more interesting problem; -)

But I would ask why? Ports are not so expensive that you cannot use two.

0
source

You do not need to run HTTP and HTTPS on the same port, configure Tomcat to redirect requests to HTTPS in the server.xml file.

-1
source

Well, I wonder why they are NOT in the same port! wouldn't it be easier?

the reason is probably because the associated Java APIS (javax.net.ssl) does not allow this; You must have different server sockets. Are there any alternatives to SSL for Java? I do not know anything.

-1
source

Source: https://habr.com/ru/post/1309663/


All Articles