python
network_error
ai_generated
true
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host api.example.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)')]
ID: python/aiohttp-cannot-connect-to-host-ssl
80%Fix Rate
87%Confidence
0Evidence
2024-02-14First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8+ | active | — | — | — |
| 3.9+ | active | — | — | — |
| 3.10+ | active | — | — | — |
| 3.11+ | active | — | — | — |
| 3.12+ | active | — | — | — |
Root Cause
The client cannot find the CA bundle to verify the server certificate, often on macOS Python.org builds or in containers missing ca-certificates.
generic中文
客户端找不到用于验证服务器证书的 CA 证书包,常见于 macOS 官方 Python 构建或缺少 ca-certificates 的容器中。
Workarounds
-
95% success
import ssl, certifi, aiohttp ctx = ssl.create_default_context(cafile=certifi.where()) conn = aiohttp.TCPConnector(ssl=ctx) async with aiohttp.ClientSession(connector=conn) as s: ... -
90% success
# macOS /Applications/Python\ 3.12/Install\ Certificates.command
Dead Ends
Common approaches that don't work:
-
40% fail
Disables TLS verification entirely, exposing the app to MITM; often blocked by security policy.
-
90% fail
The issue is the system trust store, not the aiohttp package.