Set up a secure tunnel

MD
R
Markdown

The encryption in transit setting is also enabled (TLS). This requires that you establish a secure SSL/TLS connection to your destination service. This could be the reason why you're unable to connect using the redis-cli command, which might not be using a secure connection by default. You would need to use stunnel or a similar utility to set up a secure tunnel to your MemoryDB cluster. Here's an example using stunnel:

Explanation: TLS (Transport Layer Security) is a protocol for encryption. In the case of AWS MemoryDB, it uses TLS for encryption, which requires a secure SSL/TLS connection. But the Redis command line interface (redis-cli) does not support SSL/TLS by default You need [SOMETHING] to translate your normal TCP data into encrypted TCP data, and that's what [STUNNEL] does. Stunnel stands for "Socket Tunnel": and it's a software that provides a method for arbitrary data transfer over TLS. It allows you to add SSL/TLS functionality to an existing application without changing any code in the application itself. It's like a translator who can convert your normal TCP data into encrypted TCP.

Like so: So, you use stunnel to create a secure tunnel between your local machine and AWS MemoryDB, translating the "normal" Redis commands into "encrypted" commands that can travel securely over the internet. This way, you can use redis-cli to interact with MemoryDB, and all the data you send is encrypted and secure.

Note: The public key is included in the server's certificate, which is sent to the client when the connection is established. The private key is securely stored on the server and is used to decrypt the pre-master secret sent by the client. This mechanism allows both the client and the server to agree on a session key, which is used for encrypting and decrypting the communication.

Instructions:

  1. Install stunnel: sudo yum install stunnel

  2. Create a stunnel configuration file (e.g., /etc/stunnel/redis-cli.conf) with the following content: fips = no setuid = root setgid = root pid = /var/run/stunnel.pid debug = 7 options = NO_SSLv2 options = NO_SSLv3 [redis-cli] client = yes accept = 127.0.0.1:6379 connect = clustercfg.test-networking-reis-memory-lambda.ukcwoj.memorydb.eu-west-2.amazonaws.com:6379

  3. Run stunnel with the configuration file: sudo stunnel /etc/stunnel/redis-cli.conf

  4. Connect to your MemoryDB cluster through the secure tunnel: redis-cli -h 127.0.0.1 -p 6379

Created on 5/21/2023