Implement secure Redis SSL/TLS connection management for production#26
Merged
mnaimfaizy merged 5 commits intomainfrom Jan 3, 2026
Merged
Conversation
- Create RedisConnectionFactory with comprehensive SSL/TLS support - Add connection pooling with retry logic and exponential backoff - Implement certificate validation for production environments - Update session.py to use new connection factory - Enhance Celery SSL configuration with proper certificate validation - Improve service_config.py SSL URL generation - Add Redis connection pool cleanup in application lifecycle - Create comprehensive documentation for Redis SSL setup - Support environment-based SSL configuration (dev/test/prod) - Add health check capabilities for Redis connections - Implement strong cipher suites and TLS 1.2+ enforcement Co-authored-by: mnaimfaizy <34773846+mnaimfaizy@users.noreply.github.com>
- Add production environment configuration example (.env.production.example) - Create detailed implementation summary document - Include deployment checklist and rollback procedures - Document security improvements and compliance - Add certificate rotation and maintenance procedures - Update .gitignore to allow .env.production.example - Provide pre-deployment checklist and migration guide Co-authored-by: mnaimfaizy <34773846+mnaimfaizy@users.noreply.github.com>
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 23911355 | Triggered | SMTP credentials | 68adb93 | backend/.env.production.example | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
- Add test suite for RedisConnectionFactory - Test SSL context configuration for different environments - Test connection parameter generation - Test connection pool singleton pattern - Test health check functionality - Add integration test stubs for real Redis connections - Mock SSL context and connection pool for unit tests - Verify proper cleanup of connection pools Co-authored-by: mnaimfaizy <34773846+mnaimfaizy@users.noreply.github.com>
- Add overview README for Redis SSL improvements - Include quick start guide for dev and prod - Document security improvements and performance impact - Add troubleshooting quick reference - Include maintenance procedures - Provide testing instructions - Document compliance achievements Co-authored-by: mnaimfaizy <34773846+mnaimfaizy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate better Redis connection setup with SSL for production
Implement secure Redis SSL/TLS connection management for production
Dec 30, 2025
mnaimfaizy
approved these changes
Jan 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Production Redis connections used
ssl_cert_reqs=none, disabling certificate validation and enabling MITM attacks. No connection pooling existed, causing resource exhaustion under load. SSL configuration was inconsistent across FastAPI and Celery workers.Changes
Core Implementation
RedisConnectionFactorycentralizes connection management with environment-aware SSL configurationCERT_REQUIRED, hostname verification, strong ciphers (ECDHE+AESGCM, CHACHA20)Integration
session.py: Replaced ad-hocfrom_url()calls with factory-based clientscelery_config.py: SSL dict with proper CA cert paths instead ofssl_cert_reqs: Nonemain.py: Connection pool cleanup in application lifecycleservice_config.py: Removed insecuressl_cert_reqs=noneURL parameterDocumentation
generate-certs.sh).env.production.example)Usage
Impact
Deployment
cd backend/certs && ./generate-certs.shREDIS_SSL=true,REDIS_PASSWORD,REDIS_CERT_PATH=/app/certsdocker-compose.prod.yml(already configured)docker exec redis redis-cli --tls --cacert /certs/ca.crt pingBackward compatible: Development mode unchanged, production opt-in via
MODE=production.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.