using requests with TLS doesn#39;t give SNI support(使用带有 TLS 的请求不会提供 SNI 支持)
问题描述
我正在使用请求与 django 应用程序进行通信,但是
I'm using requests to communicate with a django app but
当我尝试时
requests.get('https://mysite.com', verify=True)
我得到错误:
主机名mysite.com"与*.myhost.com"、myhost.com"中的任何一个都不匹配
hostname 'mysite.com' doesn't match either of '*.myhost.com', 'myhost.com'
但是,当我查看浏览器时,或 http://www.digicert.com/help/ 证书看起来不错,花花公子.
However, when I look at the browser, or http://www.digicert.com/help/ the certificate looks fine and dandy.
我的主人认为这是由于请求缺乏 SNI 支持(Github 似乎证实了 https://github.com/kennethreitz/requests/issues/749).有没有人找到使用请求的解决方法?
My host suggested it was the lack of SNI support from requests (and Github seems to confirm that https://github.com/kennethreitz/requests/issues/749 ). Has anyone found a work-around using requests?
推荐答案
当前版本的 Requests 应该可以使用 SNI.再往下看 GitHub issue 你可以看到要求:
The current version of Requests should be just fine with SNI. Further down the GitHub issue you can see the requirements:
- pyOpenSSL
- ndg-httpsclient
- pyasn1
尝试安装这些软件包,然后再试一次.
Try installing those packages and then give it another shot.
编辑:从 Requests v2.12.1 开始,不再需要 ndg-httpsclient 和 pyasn1.所需软件包的完整列表现在是:
EDIT: As of Requests v2.12.1, ndg-httpsclient and pyasn1 are no longer required. The full list of required packages is now:
- pyOpenSSL
- idna
这篇关于使用带有 TLS 的请求不会提供 SNI 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用带有 TLS 的请求不会提供 SNI 支持


基础教程推荐
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 筛选NumPy数组 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01