Criptografia em trânsito com TLS
Proteja o tráfego do Redis contra espionagem habilitando TLS, configurando certificados e conectando-se com segurança a partir dos clientes.
Criptografia em trânsito com TLS é uma aula grátis de Redis Caching & Messaging (Pub/Sub, Streams) no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Redis Caching & Messaging (Pub/Sub, Streams), e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Redis Caching & Messaging (Pub/Sub, Streams) inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
Why Encrypt in Transit?
By default Redis speaks plaintext over the network. Anyone able to sniff the wire can read your commands, including AUTH passwords and cached data. TLS encrypts the connection so traffic stays confidential and tamper-evident.
TLS Building Blocks
TLS uses certificates:
- A server certificate proves the server's identity
- A private key the server keeps secret
- A CA certificate clients use to verify the server
Generating Certificates
For testing, the Redis source ships a helper script, or you can use openssl to create a CA and a server cert/key pair.
openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodesEnabling TLS on the Server
Configure the TLS port and certificate paths. Setting port 0 disables the plaintext port so only TLS is accepted.
tls-port 6379
port 0
tls-cert-file server.crt
tls-key-file server.key
tls-ca-cert-file ca.crtMutual TLS
For stronger security, require clients to present their own certificate (mTLS). The server then authenticates the client in addition to encrypting traffic.
tls-auth-clients yesConnecting with redis-cli
redis-cli supports TLS with the --tls flag plus the CA and, for mTLS, the client cert and key.
redis-cli --tls --cacert ca.crt -h myhost -p 6379Connecting from Code
Client libraries accept TLS settings: enable TLS, point to the CA, and (for mTLS) the client certificate and key.
client = redis.Redis(host='myhost', port=6379, ssl=True, ssl_ca_certs='ca.crt')Replication and Cluster over TLS
Inter-node traffic should be encrypted too. Enable tls-replication yes and tls-cluster yes so replicas and cluster bus connections also use TLS.
tls-replication yes
tls-cluster yesProtocol and Cipher Hardening
Restrict allowed protocols and ciphers to modern, strong options to avoid downgrade attacks.
tls-protocols "TLSv1.2 TLSv1.3"TLS Is Not Everything
TLS protects data in transit, not at rest, and does not replace authentication. Keep using requirepass/ACLs and bind to trusted interfaces; TLS is one layer of defense in depth.
Cost and Trade-offs
TLS adds CPU overhead for the handshake and encryption. It is usually negligible with persistent connections and connection pooling, but worth measuring under load.
Quick Check
Test your understanding of Redis TLS.
Recap
You enabled TLS on Redis: generated certificates, configured the TLS port and key/cert files, optionally required client certs for mTLS, secured replication and cluster traffic, and connected from CLI and code. Remember TLS is one layer; pair it with authentication and network isolation.
Aprenda Redis Caching & Messaging (Pub/Sub, Streams) com um tutor de IA — grátis
Escreva e execute código real no seu navegador, obtenha ajuda instantânea de um tutor de IA 24/7 e continue de onde parou na web ou no app.
- Cursos
- 12
- Aulas
- 48
Perguntas Frequentes
A aula “Criptografia em trânsito com TLS” é grátis?
Sim — o texto completo de “Criptografia em trânsito com TLS” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Redis Caching & Messaging (Pub/Sub, Streams), atualize para CoddyKit PRO. O curso de Redis Caching & Messaging (Pub/Sub, Streams) inclui 4 aulas no total.
O que vou aprender em “Criptografia em trânsito com TLS”?
Proteja o tráfego do Redis contra espionagem habilitando TLS, configurando certificados e conectando-se com segurança a partir dos clientes. Você pratica Redis Caching & Messaging (Pub/Sub, Streams) com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Redis Caching & Messaging (Pub/Sub, Streams)?
Nenhuma experiência prévia é necessária. Redis Caching & Messaging (Pub/Sub, Streams) no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.
Quanto tempo leva a aula “Criptografia em trânsito com TLS”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Redis Caching & Messaging (Pub/Sub, Streams)?
Sim. Cada aula de Redis Caching & Messaging (Pub/Sub, Streams) inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Autenticação e autorização
- Segurança de rede para Redis
- Práticas recomendadas de operação
- Criptografia em trânsito com TLS