将请求与TLS一起使用不会提供SNI支持 [英] using requests with TLS doesn't give SNI support
问题描述
我正在使用与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. 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?
推荐答案
SNI可以很好地使用Requests的当前版本. 进一步了解GitHub问题,您可以看到以下要求:
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.
编辑:从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支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!