python network_error ai_generated partial

httpx.ConnectError: [SSL: SSL_HANDSHAKE_FAILURE] SSL握手失败 (_ssl.c:1123),连接到'https://incompatible.example.com'时

httpx.ConnectError: [SSL: SSL_HANDSHAKE_FAILURE] ssl handshake failure (_ssl.c:1123) while connecting to 'https://incompatible.example.com'

ID: python/httpx-connecterror-ssl-handshake-failure

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
0证据数
2025-12-01首次发现

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

客户端和服务器无法就SSL/TLS参数达成一致,通常是由于过时的协议或密码套件不匹配。

English

The client and server cannot agree on SSL/TLS parameters, often due to outdated protocols or cipher mismatches.

generic

解决方案

  1. 90% 成功率 Update the server to support modern TLS versions (1.2 or 1.3)
    Contact server administrator to enable TLS 1.2 or higher.
  2. 80% 成功率 Configure the client to use a specific TLS version if supported
    import ssl
    context = ssl.create_default_context()
    context.minimum_version = ssl.TLSVersion.TLSv1_2
    client = httpx.Client(verify=context)
    response = client.get('https://incompatible.example.com')

无效尝试

常见但无效的做法:

  1. Disabling SSL verification 80% 失败

    Handshake failure occurs before certificate verification.

  2. Using a very old SSL version 70% 失败

    Old versions are often disabled for security reasons.