Redis 6.0新特性----TLS 通道加密

Redis 6实现了通道加密,提高了redis的安全性。Redis作为缓存数据库,里面很有可能缓存重要的敏感信息,所以支持tls通道加密还是很有必要的,当然敏感信息还是建议加密保存。

创建证书

mkdir -p tests/tls
openssl genrsa -out tests/tls/ca.key 2048
openssl req \
    -x509 -new -nodes -sha256 \
    -key tests/tls/ca.key \
    -days 3650 \
    -subj '/O=Redis Test/CN=Certificate Authority' \
    -out tests/tls/ca.crt
openssl genrsa -out tests/tls/redis.key 2048
openssl req \
    -new -sha256 \
    -key tests/tls/redis.key \
    -subj '/O=Redis Test/CN=Server' | \
    openssl x509 \
        -req -sha256 \
        -CA tests/tls/ca.crt \
        -CAkey tests/tls/ca.key \
        -CAserial tests/tls/ca.txt \
        -CAcreateserial \
        -days 365 \
        -out tests/tls/redis.crt
openssl dhparam -out tests/tls/redis.dh 2048

生成的证书如下图所示:

image.png

编译redis

使用下面命令编译redis:

make BUILD_TLS=yes -j8

编译结果如下:

image.png

启动服务端

使用下面命令启动redis服务:

./src/redis-server --tls-port 6379 --port 0 \
        --tls-cert-file ./tests/tls/redis.crt \
        --tls-key-file ./tests/tls/redis.key \
        --tls-ca-cert-file ./tests/tls/ca.crt

结果如下:

image.png

客户端链接

使用客户端链接redis服务:

./src/redis-cli --tls \
        --cert ./tests/tls/redis.crt \
        --key ./tests/tls/redis.key \
        --cacert ./tests/tls/ca.crt

结果如下:

image.png

也可以使用下面命令:

./src/redis-cli --tls --insecure

结果如下:

image.png



标 题:《Redis 6.0新特性----TLS 通道加密
作 者:zeekling
提 示:转载请注明文章转载自个人博客:浪浪山旁那个村

    评论
    9 评论
    2021-11-06 21:29 回复»

    😄

    zzc
    2021-11-06 14:33 回复»

    👍

    lss
    2021-11-06 14:01 回复»

    mark

    2021-09-18 16:26 回复»

    静态的可以用cdn的

    2021-09-06 16:44 回复»

    👍

    2021-09-05 15:33 回复»

    学习了

    2021-09-05 15:31 回复»

    学习了

    2021-09-02 15:21 回复»

    想给博客套个缓存,奈何是静态站!

    2021-08-08 17:55 回复»

    技术文章,学习了。
    80% WordPress/Typecho,都是在讲开发

avatar

取消