diff --git a/internal/redis/node.go b/internal/redis/node.go index 91b881e..bd30083 100644 --- a/internal/redis/node.go +++ b/internal/redis/node.go @@ -65,7 +65,7 @@ func NewNode(config *config.Config, logger *slog.Logger, fqdn string) (*Node, er Protocol: 2, } if config.Redis.UseTLS { - tlsConf, err := getTLSConfig(config, config.Redis.TLSCAPath) + tlsConf, err := getTLSConfig(config, config.Redis.TLSCAPath, host) if err != nil { return nil, err } diff --git a/internal/redis/senticache.go b/internal/redis/senticache.go index 65d4ed3..222432a 100644 --- a/internal/redis/senticache.go +++ b/internal/redis/senticache.go @@ -78,7 +78,7 @@ func NewSentiCacheNode(config *config.Config, logger *slog.Logger) (*SentiCacheN Protocol: 2, } if config.SentinelMode.UseTLS { - tlsConf, err := getTLSConfig(config, config.SentinelMode.TLSCAPath) + tlsConf, err := getTLSConfig(config, config.SentinelMode.TLSCAPath, localhost) if err != nil { return nil, err } diff --git a/internal/redis/tls.go b/internal/redis/tls.go index 34045a0..7d35c93 100644 --- a/internal/redis/tls.go +++ b/internal/redis/tls.go @@ -9,9 +9,11 @@ import ( "github.com/yandex/rdsync/internal/config" ) -func getTLSConfig(config *config.Config, CAPath string) (*tls.Config, error) { +func getTLSConfig(config *config.Config, CAPath, host string) (*tls.Config, error) { c := &tls.Config{} - c.ServerName = config.Hostname + if host == localhost { + c.ServerName = config.Hostname + } if CAPath != "" { cert, err := os.ReadFile(CAPath) if err != nil {