{"record":{"id":"5fe9c250533e0f97","repo":"HKUDS/DeepTutor","slug":"disable-ssl-verify-is-not-allowed-in-production","errorCode":null,"errorMessage":"DISABLE_SSL_VERIFY is not allowed in production","messagePattern":"DISABLE_SSL_VERIFY is not allowed in production","errorType":"validation","errorClass":"LLMConfigError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/llm/openai_http_client.py","lineNumber":26,"sourceCode":"from typing import Any\n\nimport httpx\n\nfrom deeptutor.services.config import load_system_settings\nfrom deeptutor.services.llm.exceptions import LLMConfigError\n\nlogger = logging.getLogger(__name__)\n\n_warning_lock = threading.Lock()\n_warning_logged = False\n\n\ndef disable_ssl_verify_enabled() -> bool:\n    \"\"\"Return whether outbound TLS verification should be disabled.\"\"\"\n    if not load_system_settings()[\"disable_ssl_verify\"]:\n        return False\n    if os.getenv(\"ENVIRONMENT\", \"\").strip().lower() in {\"prod\", \"production\"}:\n        raise LLMConfigError(\"DISABLE_SSL_VERIFY is not allowed in production\")\n    global _warning_logged\n    with _warning_lock:\n        if not _warning_logged:\n            logger.warning(\n                \"SSL verification is disabled via DISABLE_SSL_VERIFY. This is unsafe \"\n                \"and must not be used in production environments.\"\n            )\n            _warning_logged = True\n    return True\n\n\n_sanitized_lock = threading.Lock()\n_sanitized_warned: set[str] = set()\n\n# httpx passes these OpenSSL paths to ssl.create_default_context, which raises\n# FileNotFoundError when a path has gone stale after a conda env is cloned or\n# moved without ca-certificates.\n_SSL_CA_ENV_PATHS: tuple[tuple[str, str], ...] = (","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/llm/openai_http_client.py#L8-L44","documentation":"disable_ssl_verify_enabled() reads the DISABLE_SSL_VERIFY system setting; when it is enabled AND ENVIRONMENT is 'prod'/'production', it raises LLMConfigError as a hard safety guard against shipping with TLS verification off.","triggerScenarios":"System settings have disable_ssl_verify=true and the ENVIRONMENT env var equals 'prod' or 'production' (case-insensitive, whitespace-trimmed); any embed/build_openai_http_client/_call_codex call then fails.","commonSituations":"A dev-only self-signed-cert workaround accidentally promoted to production config; CI pipelines setting ENVIRONMENT=production while reusing dev settings JSON.","solutions":["Set disable_ssl_verify back to false in data/user/settings and install the CA cert properly.","If TLS interception is genuinely needed in prod, terminate it at a trusted proxy instead.","Ensure ENVIRONMENT isn't accidentally set to production in dev."],"exampleFix":"# before\n{\"disable_ssl_verify\": true}\n# after\n{\"disable_ssl_verify\": false}","handlingStrategy":"validation","validationCode":"import os\n\ndef ssl_config_safe() -> bool:\n    return not (os.getenv('ENVIRONMENT', '').lower() in ('prod', 'production')) or not load_system_settings()['disable_ssl_verify']","typeGuard":null,"tryCatchPattern":"try:\n    client = build_openai_http_client()\nexcept LLMConfigError as e:\n    if 'DISABLE_SSL_VERIFY' in str(e):\n        settings['disable_ssl_verify'] = False  # persist fix, then rebuild","preventionTips":["Add a CI check asserting disable_ssl_verify=false when ENVIRONMENT=production","Use SSL_CERT_FILE/REQUESTS_CA_BUNDLE for corporate CAs instead of disabling verification","Never copy dev settings JSON into prod images"],"tags":["ssl","security","config","production-guard"],"backgroundTag":"ssl-verification-disabled","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}