# aiohttp 客户端连接器 SSL 错误：版本号错误

- **ID:** `python/aiohttp-client-connector-ssl-handshake-error`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

服务器使用不兼容的 SSL/TLS 版本，或者客户端尝试使用 HTTPS 连接到 HTTP 服务器。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## 解决方案

1. **Use the correct URL scheme (http:// instead of https://)** (90% 成功率)
   ```
   async with session.get('http://example.com') as resp:
   ```
2. **Update the SSL context to use modern TLS versions** (85% 成功率)
   ```
   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** — This does not fix the version mismatch; it only bypasses certificate verification. (50% 失败率)
- **Using a very old SSL context that forces TLS 1.0** — Many servers now reject outdated TLS versions due to security policies. (60% 失败率)
