全站数据
8 4 2 0 5 8 1

redis怎么开启ssl

工程军事 | 简单学习,快乐成才!         
问题更新日期:2024-10-16 06:48:32

问题描述

redis怎么开启ssl急求答案,帮忙回答下
精选答案
最佳答案

redis开启ssl过程:

首先编译安装redis:

cd /usr/local/src wget https://download.redis.ioeleasesedis-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=/optedis install mkdir /dataedis;echo 'PATH=/optedis/bin:$PATH' >> /etc/profile source /etc/profile;mkdir /optedis/conf cp /usr/local/srcedis-6.0.9edis.conf /optedis/conf/ sed -i

"365s#./#/optedis/conf/#

" /optedis/confedis.conf echo vm.overcommit_memory = 1 >> /etc/sysctl.conf;sysctl -p

生成证书

mkdir /optedis/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 /optedis ./binedis-server --tls-port 6379 --port 0 --tls-cert-file ./zsedis.crt --tls-key-file ./zsedis.key --tls-ca-cert-file ./zs/ca.crt

验证tls

cd /optedis ./binedis-cli --tls --cert ./zsedis.crt --key ./zsedis.key --cacert ./zs/ca.crt