InsecurePlatformWarning:真正的SSLContext对象不可用。这可以防止urllib3适当地配置SSL [重复]

本文翻译自:InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately [duplicate]

This question already has an answer here: 这个问题在这里已有答案:

Tried to perform REST GET through python requests with the following code and I got error. 尝试使用以下代码通过python请求执行REST GET,我收到了错误。

Code snip: 代码片段:

import requests
header = {'Authorization': 'Bearer...'}
url = az_base_url + az_subscription_id + '/resourcegroups/Default-Networking/resources?' + az_api_version
r = requests.get(url, headers=header)

Error: 错误:

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:79: 
          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

My python version is 2.7.3. 我的python版本是2.7.3。 I tried to install urllib3 and requests[security] as some other thread suggests, I still got the same error. 我尝试安装urllib3并请求[安全],因为其他线程建议,我仍然有同样的错误。

Wonder if anyone can provide some tips? 想知道是否有人可以提供一些提示?


#1楼

参考:https://stackoom.com/question/1yFDU/InsecurePlatformWarning-真正的SSLContext对象不可用-这可以防止urllib-适当地配置SSL-重复


#2楼

If you are not able to upgrade your Python version to 2.7.9, and want to suppress warnings, 如果您无法将Python版本升级到2.7.9,并且想要禁止警告,

you can downgrade your 'requests' version to 2.5.3: 您可以将“请求”版本降级到2.5.3:

pip install requests==2.5.3

Bugfix disclosure / Warning introduced in 2.6.0 2.6.0中引入了 Bugfix披露 / 警告


#3楼

The docs give a fair indicator of what's required. 文档给出了所需要的公平指标。 , however requests allow us to skip a few steps: 但是requests允许我们跳过几个步骤:

You only need to install the security package extras (thanks @admdrew for pointing it out) 您只需安装security 包附加功能 (感谢@admdrew指出)

$ pip install requests[security]

or, install them directly: 或者,直接安装它们:

$ pip install pyopenssl ndg-httpsclient pyasn1

Requests will then automatically inject pyopenssl into urllib3 请求将自动将pyopenssl注入urllib3


If you're on ubuntu, you may run into trouble installing pyopenssl , you'll need these dependencies: 如果您使用的是ubuntu,则可能在安装pyopenssl遇到问题,您需要这些依赖项:

$ apt-get install libffi-dev libssl-dev
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值