用法
tls-protocols "TLSv1.2 TLSv1.3"
用途
tls-protocols
设置服务端支持的TLS协议版本。
注意事项:
1.默认仅支持 TLSv1.2
和TLSv1.3
。
2.多个版本用空格
隔开。
3.client
与server
协议版本不匹配将无法建立连接。
配置用例(本例中客户端与服务端共用一套CA证书)
redis服务端仅支持TLS1.3
tls-port 6379
tls-cert-file /Users/server.pem
tls-key-file /Users/server.key
tls-protocols "TLSv1.3"
tls-auth-clients optional
redis客户端仅支持TLS1.1
func main() {
ctx := context.Background()
pool := x509.NewCertPool()
caCert, err := ioutil.ReadFile("/Users/rootCA.pem")
if err != nil {
fmt.Println(err)
return
}
pool.AppendCertsFromPEM(caCert)
rdb := redis.NewClient(&redis.Options{
Addr: ":6379",
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS11, // 客户端支持的最小版本
MaxVersion: tls.VersionTLS11, // 客户端支持的最大版本
ClientCAs: pool,
InsecureSkipVerify: true,
},
})
_ = rdb.Get(ctx, "stringKey")
}
报错如下
remote error: tls: protocol version not supported
原生注释
# By default, only TLSv1.2 and TLSv1.3 are enabled and it is highly recommended
# that older formally deprecated versions are kept disabled to reduce the attack surface.
# You can explicitly specify TLS versions to support.
# Allowed values are case insensitive and include "TLSv1", "TLSv1.1", "TLSv1.2",
# "TLSv1.3" (OpenSSL >= 1.1.1) or any combination.
# To enable only TLSv1.2 and TLSv1.3, use:
#
# tls-protocols "TLSv1.2 TLSv1.3"
redis.conf详解目录
redis.conf详解总纲
欢迎加v交流:maxwangnan005
网友评论