Ubuntu 22.04
Sponsored Link

Redis 6 : SSL/TLS Setting2022/09/09

 
Configure SSL/TLS Setting on Redis.
[1] Create self-signed certificate.
If you use valid certificate like Let's Encrypt or others, skip this section.
root@dlp:~#
cd /etc/ssl/private

root@dlp:/etc/ssl/private#
openssl req -x509 -nodes -newkey rsa:2048 -keyout redis.pem -out redis.pem -days 3650

Generating a RSA private key
.................+++++
........+++++
writing new private key to 'vsftpd.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:JP                            # country code
State or Province Name (full name) [Some-State]:Hiroshima       # State
Locality Name (eg, city) []:Hiroshima                           # city
Organization Name (eg, company) [Internet Widgits Pty Ltd]:GTS  # company
Organizational Unit Name (eg, section) []:Server World          # department
Common Name (e.g. server FQDN or YOUR name) []:dlp.srv.world    # server's FQDN
Email Address []:root@srv.world                                 # admin's email

root@dlp:/etc/ssl/private#
chmod 600 redis.pem

[2] Configure Redis.
root@dlp:~#
cp /etc/ssl/private/redis.pem /etc/redis/

root@dlp:~#
chown redis. /etc/redis/redis.pem

root@dlp:~#
vi /etc/redis/redis.conf
# line 91 : change : disable it with [0]

port
0
# line 138: uncomment

tls-port 6379
# line 144,145 : uncomment and specify certificate

tls-cert-file
/etc/redis/redis.pem

tls-key-file
/etc/redis/redis.pem
# line 156 : uncomment

tls-ca-cert-dir /etc/ssl/certs
# line 165 : uncomment

tls-auth-clients no
root@dlp:~#
systemctl restart redis

[3] Connect to Redis with SSL/TLS from clients. If connect from other Hosts, it needs to transfer certificate to them.
root@node01:~#
ll /etc/redis

total 96
-rw-r-----   1 redis redis 85844 Mar  4  2022 redis.conf
-rw-------   1 redis redis  3160 Sep  9 02:01 redis.pem

# specify [tls] option and certificate
root@node01:~# redis-cli -h dlp.srv.world --tls \
--cert /etc/redis/redis.pem \
--key /etc/redis/redis.pem \
--cacert /etc/redis/redis.pem

dlp.srv.world:6379> auth password 
OK
dlp.srv.world:6379> info
# Server
redis_version:6.0.16
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:a3fdef44459b3ad6
redis_mode:standalone
os:Linux 5.15.0-25-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:11.2.0
process_id:12733
run_id:af822cba1ec1b6d60211ecb26d6877c9292cb364
tcp_port:6379
uptime_in_seconds:18
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:1744616
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf
io_threads_active:0
.....
.....
Matched Content