python - urllib3 文档告诉我做什么?

标签 python ssl openstack urllib3 keystone

我正在尝试部署 Kilo OpenStack 云,但出现此错误:

Execution of '/usr/bin/openstack token issue --format value' returned 1: /usr/lib/python2.7/site-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

我发现我无法访问高于 2.7.5 的 python 版本,所以我查看:

https://urllib3.readthedocs.org/en/latest/security.html#pyopenssl

所以按照他们的建议去做...

# pip install pyopenssl ndg-httpsclient pyasn1
/usr/lib/python2.7/site-packages/pip/_vendor/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
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already satisfied (use --upgrade to upgrade): pyopenssl in /usr/lib64/python2.7/site-packages
Collecting ndg-httpsclient
/usr/lib/python2.7/site-packages/pip/_vendor/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
  Downloading ndg_httpsclient-0.4.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /usr/lib/python2.7/site-packages
Installing collected packages: ndg-httpsclient
  Running setup.py install for ndg-httpsclient
Successfully installed ndg-httpsclient-0.4.0

文档也这样说:

Once the packages are installed, you can tell urllib3 to switch the ssl backend to PyOpenSSL with inject_into_urllib3():

import urllib3.contrib.pyopenssl urllib3.contrib.pyopenssl.inject_into_urllib3() Now you can continue using urllib3 as you normally would.

我不明白这是什么意思?有没有我需要打补丁的 python 源代码?

更新:

我按照 Josep 的建议做了,这就是正在发生的事情:

# python
Python 2.7.5 (default, Jun 24 2015, 00:41:19) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib3
>>> import pyopenssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyopenssl

但是我已经安装了 pyopenssl ...

# pip install pyopenssl
Requirement already satisfied (use --upgrade to upgrade): pyopenssl in /usr/lib64/python2.7/site-packages

更新:

如果我这样做会发生什么......

# python
Python 2.7.5 (default, Jun 24 2015, 00:41:19) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL
>>> import urllib3
>>> import urllib3.contrib.pyopenssl as pyopenssl
>>> pyopenssl.inject_into_urllib3()
>>> 

最佳答案

我了解到您正在使用使用 urllib3 的 OpenStack。所以是的,如果您想走那条路并“修补” OpenStack,请寻找类似 import .*urllib3.*from urllib3 import .* 并在每个实例之后添加他们指示您添加的两行。

关于python - urllib3 文档告诉我做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34075329/

相关文章:

python - pymongo 在尝试连接到本地 Mongo 实例时返回 SSL 错误

python - Openstack python API : how to download image from glance using the python api

ubuntu - 无法建立与 http ://controller:9696/v2. 0/networks 的连接

python - 为什么定期按回车键会大大加快我的代码速度?

python - 我的代码正在处理字典列表,就像字符串一样,类型错误: TypeError: string indices must be integers

python - flask_mail,邮件卡在线程上,从未发送过

asp.net - 为什么 appcmd.exe 解锁配置在 Azure 模拟器上不起作用?

kubernetes - OpenShift::POD 未从部署配置继承 "name label"

javascript - jquery中的Ajax调用刷新Django中的数据库模型

python - boost python hello程序上的导入错误