diff --git a/weed/filer/redis2/redis_store.go b/weed/filer/redis2/redis_store.go index 4de0504f1..7193699f9 100644 --- a/weed/filer/redis2/redis_store.go +++ b/weed/filer/redis2/redis_store.go @@ -40,6 +40,12 @@ func (store *Redis2Store) Initialize(configuration util.Configuration, prefix st } func (store *Redis2Store) initialize(hostPort string, username string, password string, database int, keyPrefix string, superLargeDirectories []string, enableMtls bool, caCertPath string, clientCertPath string, clientKeyPath string) (err error) { + opt := &redis.Options{ + Addr: hostPort, + Username: username, + Password: password, + DB: database, + } if enableMtls { clientCert, err := tls.LoadX509KeyPair(clientCertPath, clientKeyPath) if err != nil { @@ -61,27 +67,14 @@ func (store *Redis2Store) initialize(hostPort string, username string, password glog.Fatalf("Error parsing redis host and port from %s: %v", hostPort, err) } - tlsConfig := &tls.Config{ + opt.TLSConfig = &tls.Config{ Certificates: []tls.Certificate{clientCert}, RootCAs: caCertPool, ServerName: redisHost, MinVersion: tls.VersionTLS12, } - store.Client = redis.NewClient(&redis.Options{ - Addr: hostPort, - Username: username, - Password: password, - DB: database, - TLSConfig: tlsConfig, - }) - } else { - store.Client = redis.NewClient(&redis.Options{ - Addr: hostPort, - Username: username, - Password: password, - DB: database, - }) } + store.Client = redis.NewClient(opt) store.keyPrefix = keyPrefix store.loadSuperLargeDirectories(superLargeDirectories) return