According to the documentation If verify_server_hostname
is set, then outgoing connections perform hostname verification. All servers must have a certificate valid for server.<datacenter>.<domain>
or the client will reject the handshake. This is a new configuration as of 0.5.1, and it is used to prevent a compromised client from being able to restart in server mode and perform a MITM (Man-In-The-Middle) attack. New deployments should set this to true, and generate the proper certificates, but this is defaulted to false to avoid breaking existing deployments.
I tried to test this behaviour before deploing production cluser using ‘learn-repo’. I generated client cert and use the example from ‘datacenter-deploy-secure’ folder.
As a result I see that client joined to the cluster as a server:
/ # consul members
Node Address Status Type Build Protocol DC Partition Segment
consul-client 172.19.0.2:8301 alive server 1.11.2 2 dc1 default
consul-server1 172.19.0.4:8301 alive server 1.11.2 2 dc1 default
consul-server2 172.19.0.5:8301 alive server 1.11.2 2 dc1 default
consul-server3 172.19.0.3:8301 alive server 1.11.2 2 dc1 default
And it is even a voter:
/ # consul operator raft list-peers
Node ID Address State Voter RaftProtocol
consul-server2 29b4df30-023c-440a-e4fa-52d8a8e7ea36 172.19.0.5:8300 follower true 3
consul-server1 636bb8d9-102c-c208-5d25-f7f451739c70 172.19.0.4:8300 leader true 3
consul-client 0c3e5c6a-1f52-7eab-5b0b-87de3b90f1c1 172.19.0.2:8300 follower true 3
consul-server3 4ae9f80c-d082-943b-7521-67226206c265 172.19.0.3:8300 follower true 3
The only place where I see any problems is client logs with messages:
2024-05-08T09:18:56.166Z [ERROR] agent.server.rpc: failed to read byte: conn=from=172.19.0.4:53752 error=“remote error: tls: bad certificate”
2024-05-08T09:18:58.185Z [ERROR] agent.server.rpc: failed to read byte: conn=from=172.19.0.4:53760 error=“remote error: tls: bad certificate”
2024-05-08T09:18:58.188Z [ERROR] agent.server.rpc: failed to read byte: conn=from=172.19.0.4:53770 error=“remote error: tls: bad certificate”
2024-05-08T09:18:58.515Z [ERROR] agent.server.rpc: failed to read byte: conn=from=172.19.0.4:53786 error=“remote error: tls: bad certificate”
2024-05-08T09:18:58.592Z [ERROR] agent: Coordinate update error: error=“No cluster leader”
For me looks very strange, so I want to ask: Option ‘verify_server_hostname’ is intended to work this way or I have something misconfigured?