Fix redis ssl issues

This commit is contained in:
2026-01-24 19:12:35 +01:00
parent a65789974b
commit 08f84e951a
9 changed files with 72 additions and 17 deletions

View File

@@ -365,6 +365,7 @@ class AlertEventConsumer:
# Redis-based rate limiting implementation
try:
import ssl
import redis.asyncio as redis
from datetime import datetime, timedelta
from app.core.config import Settings
@@ -372,7 +373,13 @@ class AlertEventConsumer:
# Connect to Redis using proper configuration with TLS and auth
settings = Settings()
redis_url = settings.REDIS_URL
redis_client = await redis.from_url(redis_url, decode_responses=True)
# Handle SSL/TLS for self-signed certificates
connection_kwargs = {"decode_responses": True}
if redis_url and redis_url.startswith("rediss://"):
connection_kwargs["ssl_cert_reqs"] = ssl.CERT_NONE
redis_client = await redis.from_url(redis_url, **connection_kwargs)
# Rate limit keys
hour_key = f"alert_rate_limit:{tenant_id}:{alert_type}:hour:{datetime.utcnow().strftime('%Y%m%d%H')}"