kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

Support SNI on TLS replication connections

Open M4t7e opened this issue 2 months ago • 1 comments

Search before asking

  • [x] I had searched in the issues and found no similar issues.

Motivation

Kvrocks supports encrypted replication using:

tls-replication yes
replicaof kvrocks.example.com 6666

However, the replica's TLS client does not send the Server Name Indication (SNI), even when replicaof contains a DNS hostname.

This prevents replication through TLS-aware Layer 4 routing implementations that use SNI to select a backend, such as Kubernetes Gateway API TLSRoute.

Solution

Use the host from replicaof as the SNI server name for every TLS replication connection.

Before starting the TLS handshake, use inet_pton() to determine whether the configured host is a literal IPv4 or IPv6 address. If it is not an IP address, treat it as a DNS hostname and set it as the SNI server name.

Are you willing to submit a PR?

  • [x] I'm willing to submit a PR!

M4t7e avatar Sep 15 '26 14:09 M4t7e

Hi! I'm interested in contributing to Kvrocks and have been looking into this issue.

I noticed that PR #3623 is still open. Would there be any specific parts of the implementation or testing that could use additional help? I'd be happy to investigate a follow-up task or help address any outstanding review feedback.

Thanks!

yaolele05 avatar Oct 15 '26 12:10 yaolele05