التشفير أثناء النقل باستخدام TLS
احمِ حركة مرور Redis من التنصت بتمكين TLS وتهيئة الشهادات والاتصال بأمان من العملاء
التشفير أثناء النقل باستخدام TLS درس مجاني في Redis Caching & Messaging (Pub/Sub, Streams) على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Redis Caching & Messaging (Pub/Sub, Streams)، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Redis Caching & Messaging (Pub/Sub, Streams) 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
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.
الأسئلة الشائعة
هل درس «التشفير أثناء النقل باستخدام TLS» مجاني؟
نعم — نص درس «التشفير أثناء النقل باستخدام TLS» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Redis Caching & Messaging (Pub/Sub, Streams)، انتقل إلى CoddyKit PRO. تتضمن دورة Redis Caching & Messaging (Pub/Sub, Streams) 4 دروس في المجموع.
ماذا ستتعلم في «التشفير أثناء النقل باستخدام TLS»؟
احمِ حركة مرور Redis من التنصت بتمكين TLS وتهيئة الشهادات والاتصال بأمان من العملاء تتمرن على Redis Caching & Messaging (Pub/Sub, Streams) مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Redis Caching & Messaging (Pub/Sub, Streams)؟
لا تُشترط خبرة سابقة. Redis Caching & Messaging (Pub/Sub, Streams) على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «التشفير أثناء النقل باستخدام TLS»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Redis Caching & Messaging (Pub/Sub, Streams) هذا؟
نعم. كل درس في Redis Caching & Messaging (Pub/Sub, Streams) يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- المصادقة والتفويض
- أمن الشبكات في Redis
- أفضل الممارسات التشغيلية
- التشفير أثناء النقل باستخدام TLS