redis6.0.9配置ssl认证

跟風遠走 提交于 2021-02-17 22:47:02

官网参考
https://redis.io/topics/encryption./bin/redis-cli --tls --cert ./zs/redis.crt --key ./zs/redis.key --cacert ./zs/ca.crt

编译安装

cd /usr/local/src
wget https://download.redis.io/releases/redis-6.0.9.tar.gz
tar xf redis-6.0.9.tar.gz -C /opt
cd redis-6.0.9
make MALLOC=libc BUILD_TLS=yes
make PREFIX=/opt/redis install
mkdir /data/redis;echo 'PATH=/opt/redis/bin:$PATH' >> /etc/profile 
source /etc/profile;mkdir /opt/redis/conf 
cp /usr/local/src/redis-6.0.9/redis.conf /opt/redis/conf/
sed -i "365s#./#/opt/redis/conf/#" /opt/redis/conf/redis.conf
echo vm.overcommit_memory = 1 >> /etc/sysctl.conf;sysctl -p

生成证书

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

启动redis

cd /opt/redis
./bin/redis-server --tls-port 6379 --port 0 --tls-cert-file ./zs/redis.crt --tls-key-file ./zs/redis.key --tls-ca-cert-file ./zs/ca.crt

验证tls

cd /opt/redis
./bin/redis-cli --tls --cert ./zs/redis.crt --key ./zs/redis.key --cacert ./zs/ca.crt
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!