【问题标题】:SSL library on Python 2.7.10 does not contain PROTOCOL_TLSv1_2 and upgrading SSL library results in errorPython 2.7.10 上的 SSL 库不包含 PROTOCOL_TLSv1_2 并且升级 SSL 库会导致错误
【发布时间】:2015-08-14 00:56:45
【问题描述】:

尝试使用ssl.PROTOCOL_TLSv1_2 使用 Python 2.X 发出 TLS1.2 HTTPS 请求。

在此线程 (Sending TLS 1.2 request in Python 2.6) 中建议我需要从 Python 2.7.6 切换到 2.7.10,我这样做了,然后使用 ssl 库。

很遗憾,在切换到 Python 2.7.10 后,我无法访问ssl.PROTOCOL_TLSv1_2(显然我无法发布图片)。

我很确定我使用的是 Python 2.7.10,因为当我激活我的虚拟环境并从命令行调用 Python 时,我看到:

Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information.

我认为问题可能在于 ssl 库已过时,这就是我在尝试 pip install ssl --upgrade 时看到的内容

Collecting ssl Using cached ssl-1.16.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 20, in <module> File "/private/var/folders/xl/nl55_c357zd2gqs09wfwytvh0000gn/T/pip-build-tn97bV/ssl/setup.py", line 12, in <module> + "or earlier.") ValueError: This extension should not be used with Python 2.6 or later (already built in), and has not been tested with Python 2.3.4 or earlier.

【问题讨论】:

标签: python-2.7


【解决方案1】:

面临同样的问题。尝试用 ssl.PROTOCOL_TLSv1 替换。

还要确保您的 SSL 版本 >= 1.0.1 。

它对我有用。

【讨论】:

【解决方案2】:

我使用的是 python2.7.10。我将我的环境更改为 python2.7.13,它使用最新版本的 ssl 解决了这个问题。谢谢。

【讨论】:

  • 它不起作用,完全不建议使用python 2.7.x,因此最好将python版本升级到最新并尝试使用TLSv1_1/TLSv1_2。
猜你喜欢
  • 2018-09-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-15
  • 2017-03-19
  • 2021-09-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多