{"record":{"id":"176e31c2c47756ab","repo":"arduino/Arduino","slug":"can-t-connect-to-https-url-because-the-ssl-module","errorCode":null,"errorMessage":"Can't connect to HTTPS URL because the SSL module is not available.","messagePattern":"Can't connect to HTTPS URL because the SSL module is not available\\.","errorType":"exception","errorClass":"SSLError","httpStatus":null,"severity":"critical","filePath":"arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/connectionpool.py","lineNumber":537,"sourceCode":"                                    strict, timeout, maxsize,\n                                    block, headers)\n        self.key_file = key_file\n        self.cert_file = cert_file\n        self.cert_reqs = cert_reqs\n        self.ca_certs = ca_certs\n        self.ssl_version = ssl_version\n\n    def _new_conn(self):\n        \"\"\"\n        Return a fresh :class:`httplib.HTTPSConnection`.\n        \"\"\"\n        self.num_connections += 1\n        log.info(\"Starting new HTTPS connection (%d): %s\"\n                 % (self.num_connections, self.host))\n\n        if not ssl: # Platform-specific: Python compiled without +ssl\n            if not HTTPSConnection or HTTPSConnection is object:\n                raise SSLError(\"Can't connect to HTTPS URL because the SSL \"\n                               \"module is not available.\")\n\n            return HTTPSConnection(host=self.host,\n                                   port=self.port,\n                                   strict=self.strict)\n\n        connection = VerifiedHTTPSConnection(host=self.host,\n                                             port=self.port,\n                                             strict=self.strict)\n        connection.set_cert(key_file=self.key_file, cert_file=self.cert_file,\n                            cert_reqs=self.cert_reqs, ca_certs=self.ca_certs)\n\n        connection.ssl_version = self.ssl_version\n\n        return connection\n\n\ndef connection_from_url(url, **kw):","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/connectionpool.py#L519-L555","documentation":"urllib3 raises this SSLError in HTTPSConnectionPool._new_conn when the Python runtime has no usable `ssl` module. The code checks `if not ssl:` and, because the stdlib SSL-backed HTTPSConnection is also unavailable, it cannot build any HTTPS connection and aborts. This is an environment/build problem, not a network problem: the interpreter was compiled without SSL support (or OpenSSL bindings failed to load).","triggerScenarios":"Any call that opens an HTTPS URL through urllib3 (e.g. requests.get('https://...'), urllib3.connectionpool.HTTPSConnectionPool.request) when `import ssl` fails because Python was compiled without the _ssl module, typically a from-source build without OpenSSL headers.","commonSituations":"Python built with pyenv/compile on Ubuntu/Debian missing libssl-dev; a hand-built interpreter without openssl headers; stripped-down Python distributions or embedded builds without the _ssl module; broken OpenSSL upgrade leaving _ssl.so unloadable.","solutions":["Verify the diagnosis: run `python -c \"import ssl; print(ssl.OPENSSL_VERSION)\"`; an ImportError/AttributeError confirms the missing module.","Rebuild/ reinstall Python with SSL support: install openssl headers (`sudo apt-get install libssl-dev`) then reinstall Python (pyenv: `pyenv install 3.x.x` after installing libssl-dev, or use the system/deadsnakes python).","As an interim workaround, fetch over plain HTTP if the endpoint allows it, or use an external tool (curl/wget) outside Python.","If a virtualenv/conda points at a broken interpreter, recreate it against a Python distribution that ships SSL support."],"exampleFix":"// before (shell, failing build without SSL headers)\n$ pyenv install 3.9.1   # -> _ssl module unavailable\n// after (shell)\n$ sudo apt-get install libssl-dev && pyenv install 3.9.1 && pyenv global 3.9.1\n$ python -c \"import ssl; print(ssl.OPENSSL_VERSION)\"","handlingStrategy":"fallback","validationCode":"def ssl_available():\n    try:\n        import ssl\n        return hasattr(ssl, 'OPENSSL_VERSION')\n    except Exception:\n        return False\n\nif not ssl_available():\n    raise SystemExit('Python lacks SSL support; rebuild with OpenSSL headers before using HTTPS')","typeGuard":"def has_ssl() -> bool:\n    try:\n        import ssl  # noqa: F401\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"from requests.packages.urllib3.exceptions import SSLError\ntry:\n    resp = session.get('https://example.com')\nexcept SSLError as e:\n    if 'SSL module is not available' in str(e):\n        log.critical('Rebuild Python with OpenSSL support')\n    else:\n        raise","preventionTips":["Install libssl-dev/openssl headers before compiling Python from source (pyenv, docker builds).","Add `import ssl; ssl.OPENSSL_VERSION` to environment smoke tests in CI.","Prefer official Python builds or distro packages that ship the _ssl module.","After OpenSSL upgrades, reinstall/rebuild Python to keep _ssl.so linked correctly."],"tags":["python","ssl","tls","network","environment"],"backgroundTag":"missing-optional-dependency","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}