使用带有 TLS 的请求不提供 SNI 支持 [英] using requests with TLS doesn't give SNI support

查看:16
本文介绍了使用带有 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 问题,您可以看到要求:

The current version of Requests should be just fine with SNI. Further down the GitHub issue you can see the requirements:

尝试安装这些软件包,然后再试一次.

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:

这篇关于使用带有 TLS 的请求不提供 SNI 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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