{"id":"84aa1fa270742847","repo":"redis/redis-py","slug":"python-wasn-t-built-with-ssl-support","errorCode":null,"errorMessage":"Python wasn't built with SSL support","messagePattern":"Python wasn't built with SSL support","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"critical","filePath":"redis/asyncio/connection.py","lineNumber":1535,"sourceCode":"\n    def __init__(\n        self,\n        ssl_keyfile: Optional[str] = None,\n        ssl_certfile: Optional[str] = None,\n        ssl_cert_reqs: Union[str, ssl.VerifyMode] = \"required\",\n        ssl_include_verify_flags: Optional[List[\"ssl.VerifyFlags\"]] = None,\n        ssl_exclude_verify_flags: Optional[List[\"ssl.VerifyFlags\"]] = None,\n        ssl_ca_certs: Optional[str] = None,\n        ssl_ca_data: Optional[str] = None,\n        ssl_ca_path: Optional[str] = None,\n        ssl_check_hostname: bool = True,\n        ssl_min_version: Optional[TLSVersion] = None,\n        ssl_ciphers: Optional[str] = None,\n        ssl_password: Optional[str] = None,\n        **kwargs,\n    ):\n        if not SSL_AVAILABLE:\n            raise RedisError(\"Python wasn't built with SSL support\")\n\n        self.ssl_context: RedisSSLContext = RedisSSLContext(\n            keyfile=ssl_keyfile,\n            certfile=ssl_certfile,\n            cert_reqs=ssl_cert_reqs,\n            include_verify_flags=ssl_include_verify_flags,\n            exclude_verify_flags=ssl_exclude_verify_flags,\n            ca_certs=ssl_ca_certs,\n            ca_data=ssl_ca_data,\n            ca_path=ssl_ca_path,\n            check_hostname=ssl_check_hostname,\n            min_version=ssl_min_version,\n            ciphers=ssl_ciphers,\n            password=ssl_password,\n        )\n        super().__init__(**kwargs)\n\n    def _connection_arguments(self) -> Mapping:","sourceCodeStart":1517,"sourceCodeEnd":1553,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/connection.py#L1517-L1553","documentation":"Raised as a RedisError from SSLConnection.__init__ when the module-level flag SSL_AVAILABLE is False - i.e. the running Python interpreter was compiled without the ssl module. Constructing an SSLConnection (via rediss:// URL, ssl=True, or connection_class=SSLConnection) is impossible because there is no ssl module to build an SSLContext from.","triggerScenarios":"redis.asyncio.from_url('rediss://...'), Redis(ssl=True), or explicitly passing connection_class=SSLConnection on a Python build where 'import ssl' fails. SSL_AVAILABLE is computed at import time in redis.utils.","commonSituations":"Custom/slim Python builds (--disable-ssl or missing OpenSSL headers at build time); some embedded interpreters; minimal distroless images lacking libssl; Python compiled against an incompatible OpenSSL; CI matrices with a 'no-ssl' variant.","solutions":["Install/rebuild Python with OpenSSL available (apt-get install libssl-dev / dnf install openssl-devel, then recompile).","Use a standard CPython distribution or official docker image that includes ssl.","If SSL is genuinely unavailable, connect without TLS (redis:// instead of rediss://).","In containers, ensure ca-certificates and openssl libs are installed."],"exampleFix":"// before - python built without ssl\nr = redis.asyncio.from_url(\"rediss://host:6379\")\n\n// after - rebuild python with ssl, then the same code works\nr = redis.asyncio.from_url(\"rediss://host:6379\")","handlingStrategy":"validation","validationCode":"from redis.utils import SSL_AVAILABLE\ndef assert_tls_capable():\n    if not SSL_AVAILABLE:\n        raise RuntimeError(\"Python interpreter has no ssl module; cannot use rediss://\")","typeGuard":"def tls_available() -> bool:\n    from redis.utils import SSL_AVAILABLE\n    return bool(SSL_AVAILABLE)","tryCatchPattern":"from redis.exceptions import RedisError\ntry:\n    r = redis.asyncio.from_url(\"rediss://host\")\nexcept RedisError as e:\n    if \"SSL support\" in str(e):\n        # fall back to plaintext or rebuild interpreter\n        r = redis.asyncio.from_url(\"redis://host\")\n    else:\n        raise","preventionTips":["Use a standard CPython build / official image that includes ssl.","Install libssl-dev/openssl-devel and ca-certificates.","Gate TLS usage behind an SSL_AVAILABLE check in config code."],"tags":["ssl","environment","build","tls","async"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}