I have to secure the microservices internal communication using SSL. All my microservices are spring boot application where we are using zookeeper as discovery server. The internal service communication takes place via rest template and feign client. we are using ribbon as client side load balancer. We have set the following properties in all the microservices
spring.application.name=Application1
spring.cloud.zookeeper.discovery.enabled=true
spring.cloud.zookeeper.connectString=localhost:2181
spring.cloud.zookeeper.enabled=true
server.port=7800
spring.cloud.zookeeper.discovery.instance-ssl-port=7801
server.ssl.enabled=true
server.ssl.key-store-type=JKS
server.ssl.key-store=classpath:LP-PF1HMVQU.jks
server.ssl.key-store-password=123456
server.ssl.key-alias=LP-PF1HMVQU
server.ssl.protocol=TLS
We have to use self signed certificate, i have generated the same and imported the certicate to JRE trust store to make the communication possible (SSL Handshake). The catch here is that i had to keep the CN of the certificate same as my system's host name (LP-PF1HMVQU). This is because when the service is registered with zookeeper, it stores machine name or hostname as its address and same is retured during the handshake.
Service registered on zookeeper
{"name":"employee-service","id":"b4c2204a-b00c-4102-b609-17d7f73f35d7","address":"LP-PF1HMVQU","port":7800,"sslPort":null,"payload":{"@class":"org.springframework.cloud.zookeeper.discovery.ZookeeperInstance","id":"application-1","name":"employee-service","metadata":{}},"registrationTimeUTC":1564658801106,"serviceType":"DYNAMIC","uriSpec":{"parts":[{"value":"scheme","variable":true},{"value":"://","variable":false},{"value":"address","variable":true},{"value":":","variable":false},{"value":"port","variable":true}]}}
Now in Production we will have a docker container for each service and there can be multiple docker containers for each service. These docker containers are registered to zookeeper and it keeps the IP-Address of the container.
How should i create the certificate, what should be the CN name, so that it matches any IP-Address. I have tried the wildcard * as the CN name but it did not work.
Please suggest how to achieve this.