AttributeError: '_socketobject' 对象没有属性 'set_tlsext_host_name' [英] AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'

查看:34
本文介绍了AttributeError: '_socketobject' 对象没有属性 'set_tlsext_host_name'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 python 中,在 Ubuntu 服务器上,我试图让 requests 库发出 https 请求,如下所示:

In python, on a Ubuntu server, I am trying to get the requests library to make https requests, like so:

import requests
requests.post("https://example.com")

起初,我得到以下信息:

At first, I got the following:

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90:InsecurePlatformWarning:真正的 SSLContext 对象不可用.这会阻止 urllib3 正确配置 SSL,并可能导致某些 SSL 连接失败.有关更多信息,请参阅https://urllib3.readthedocs.org/en/latest/security.html#不安全平台警告.

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

遵循此问题中的建议后:InsecurePlatformWarning:真正的 SSLContext 对象不可用.这会阻止 urllib3 正确配置 SSL,我现在已将警告升级为以下错误:

After following the advice in this question: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately, I have now upgraded my warning to the following error:

AttributeError: '_socketobject' 对象没有属性'set_tlsext_host_name'

AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'

我该如何解决这个问题?

How do I fix this?

推荐答案

对我来说修复如下:

sudo apt-get purge python-openssl
sudo pip install pyopenssl

这篇关于AttributeError: '_socketobject' 对象没有属性 'set_tlsext_host_name'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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