python
network_error
ai_generated
true
aiohttp 客户端连接器 SSL 错误:版本号错误
aiohttp.client_exceptions.ClientConnectorSSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number
ID: python/aiohttp-client-connector-ssl-handshake-error
80%修复率
83%置信度
0证据数
2025-11-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
根因分析
服务器使用不兼容的 SSL/TLS 版本,或者客户端尝试使用 HTTPS 连接到 HTTP 服务器。
English
The server is using an incompatible SSL/TLS version, or the client is trying to connect with HTTPS to an HTTP server.
解决方案
-
90% 成功率 Use the correct URL scheme (http:// instead of https://)
async with session.get('http://example.com') as resp: -
85% 成功率 Update the SSL context to use modern TLS versions
import ssl ssl_context = ssl.create_default_context() ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2 connector = aiohttp.TCPConnector(ssl=ssl_context) async with aiohttp.ClientSession(connector=connector) as session:
无效尝试
常见但无效的做法:
-
Disabling SSL verification with ssl=False
50% 失败
This does not fix the version mismatch; it only bypasses certificate verification.
-
Using a very old SSL context that forces TLS 1.0
60% 失败
Many servers now reject outdated TLS versions due to security policies.