python3.11SSL: SSLV3_ALERT_HANDSHAKE_FAILURE

参考:python request包 版本不兼容 报错sslv3 alert handshake failure 解决方法-CSDN博客

修改:Python311\Lib\site-packages\urllib3\util\ssl_.py

新版本3.11里默认没有DEFAULT_CIPHERS

补回来:

#__imported from 3.6.8
# A secure default.
# Sources for more information on TLS ciphers:
#
# - https://wiki.mozilla.org/Security/Server_Side_TLS
# - https://www.ssllabs.com/projects/best-practices/index.html
# - https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
#
# The general intent is:
# - prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE),
# - prefer ECDHE over DHE for better performance,
# - prefer any AES-GCM and ChaCha20 over any AES-CBC for better performance and
#   security,
# - prefer AES-GCM over ChaCha20 because hardware-accelerated AES is common,
# - disable NULL authentication, MD5 MACs, DSS, and other
#   insecure ciphers for security reasons.
# - NOTE: TLS 1.3 cipher suites are managed through a different interface
#   not exposed by CPython (yet!) and are enabled by default if they're available.
DEFAULT_CIPHERS = ":".join(
    [
        "ECDHE+AESGCM",
        "ECDHE+CHACHA20",
        "DHE+AESGCM",
        "DHE+CHACHA20",
        "ECDH+AESGCM",
        "DH+AESGCM",
        "ECDH+AES",
        "DH+AES",
        "RSA+AESGCM",
        "RSA+AES",
        "!aNULL",
        "!eNULL",
        "!MD5",
        "!DSS",
    ]
)

_TYPE_PEER_CERT_RET = typing.Union["_TYPE_PEER_CERT_RET_DICT", bytes, None]

第二处:create_urllib3_context函数里

    # Unless we're given ciphers defer to either system ciphers in
    # the case of OpenSSL 1.1.1+ or use our own secure default ciphers.
    if ciphers:
        context.set_ciphers(ciphers)
    else: #added by from 3.6.8
        context.set_ciphers(DEFAULT_CIPHERS)

修改这处之后,不再报握手错误,正常连接

相关推荐

  1. <span style='color:red;'>python</span>_<span style='color:red;'>3</span>

    python_3

    2024-07-19 16:24:01      31 阅读
  2. 2024/3/31学习总结

    2024-07-19 16:24:01       36 阅读
  3. 2023.12.31 python总结

    2024-07-19 16:24:01       44 阅读
  4. Event A/Event B -- 3GPP TS 36.331

    2024-07-19 16:24:01       27 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 16:24:01       70 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 16:24:01       74 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 16:24:01       62 阅读
  4. Python语言-面向对象

    2024-07-19 16:24:01       72 阅读

热门阅读

  1. 最短路径算法——A*算法

    2024-07-19 16:24:01       21 阅读
  2. Vue进阶之Vue无代码可视化项目(七)

    2024-07-19 16:24:01       20 阅读
  3. Gmsh教程

    2024-07-19 16:24:01       21 阅读
  4. 在 Ubuntu Server 22.04 上安装 Docker 的详细步骤

    2024-07-19 16:24:01       20 阅读
  5. 航班管理系统【C语言版】单文件编写

    2024-07-19 16:24:01       18 阅读