Python 2.7.10 上的 SSL 库不包含 PROTOCOL_TLSv1_2,升级 SSL 库会导致错误 [英] SSL library on Python 2.7.10 does not contain PROTOCOL_TLSv1_2 and upgrading SSL library results in error

查看:43
本文介绍了Python 2.7.10 上的 SSL 库不包含 PROTOCOL_TLSv1_2,升级 SSL 库会导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

在此线程中建议(发送 TLS 1.2 请求在 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,2015 年 5 月 23 日,09:33:12)[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] 在达尔文输入帮助"、版权"、信用"或许可"以获取更多信息.

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

<代码>收集ssl使用缓存的 ssl-1.16.tar.gz命令 python setup.py egg_info 的完整输出:回溯(最近一次调用最后一次):文件<string>",第 20 行,在 <module> 中文件/private/var/folders/xl/nl55_c357zd2gqs09wfwytvh0000gn/T/pip-build-tn97bV/ssl/setup.py",第12行,在<module>+ "或更早.")ValueError:此扩展不应与 Python 2.6 或更高版本(已内置)一起使用,并且尚未在 Python 2.3.4 或更早版本中进行测试.

解决方案

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

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

它对我有用.

Trying to use ssl.PROTOCOL_TLSv1_2 to make TLS1.2 HTTPS requests using Python 2.X.

It was suggested in this thread (Sending TLS 1.2 request in Python 2.6) that I need to switch from Python 2.7.6 to 2.7.10, which I did, and then utilize the ssl library.

Unfortunately, after switching to Python 2.7.10, I was unable to access ssl.PROTOCOL_TLSv1_2 (apparently I can't post images).

I'm fairly sure I'm using Python 2.7.10 because when I activate my virtual environment and call Python from the command line I see:

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.

I thought maybe that the issue was that the ssl library was out of date, and this is what I saw when I tried to 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.

解决方案

Faced the same issue. Try replacing with ssl.PROTOCOL_TLSv1.

Also make sure your SSL version is >= 1.0.1 .

It worked for me .

这篇关于Python 2.7.10 上的 SSL 库不包含 PROTOCOL_TLSv1_2,升级 SSL 库会导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆