简体   繁体   中英

2-way tls in java, between two servers

I have two servers in which one server behaves as a client for the other server for some data, both the servers are deployed in two different tomcats, I want to implement 2-way tls between them, my question is do I need to open TLS communication in some other port or can use the same tomcat 8080 port as I see the code:

SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); 
SSLSocket sslSock = (SSLSocket) factory.createSocket("localhost",8095);

what, my though process is, that in both the server can provide some REST based service that can do certificate verification

Please help, as I am new to this concept

If you have not changed the default 8080 port on which Tomcat accepts your normal HTTP requests then yes, you do have to use a different port. No port on your machine can be opened twice for listening.

However, if you want to provide an HTTP API behind your SSL/TLS port then you probably want to configure your Tomcat to additionally accept HTTP request on an SSL port or set up a reverse proxy before your Tomcat to receive HTTP traffic in plain and via SSL and forward them to the same Tomcat HTTP port (8080 most likely in your case). Such a reverse proxy is usually set up as an Apache or Nginx Server .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM