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.

嘗試用下面的代碼執行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. I tried to install urllib3 and requests[security] as some other thread suggests, I still got the same error.

我的python版本是2.7.3。我嘗試安裝urllib3並請求[安全性],就像其他線程建議的那樣,我仍然有相同的錯誤。

Wonder if anyone can provide some tips?

想知道是否有人能提供一些建議?

2 个解决方案

#1


534  

The docs give a fair indicator of what's required., however requests allow us to skip a few steps:

文檔給出了所需內容的公平指標。但是,請求允許我們跳過幾個步驟:

You only need to install the security package extras (thanks @admdrew for pointing it out)

您只需安裝額外的安全包(感謝@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

#2


68  

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中引入的錯誤信息披露/警告


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/03/18/725be896275e11cae0c4e04a5cdd1324.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com