什么是urllib3文档告诉我要做什么?

时间:2015-12-03 20:15:12

标签: python ssl openstack urllib3 keystone

我正在尝试部署Kilo OpenStack云,我收到了这个错误:

  

返回执行'/ usr / bin / openstack令牌问题 - 格式化值'   1:   /usr/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90:   InsecurePlatformWarning:真正的SSLContext对象不可用。   这可以防止urllib3适当地配置SSL并可能导致   某些SSL连接失败。有关更多信息,请参阅

所以我去: 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

文档也说这个:

  

安装软件包后,您可以告诉urllib3切换软件包   ssl使用inject_into_urllib3()后端到PyOpenSSL:

     

import urllib3.contrib.pyopenssl   urllib3.contrib.pyopenssl.inject_into_urllib3()现在你可以继续了   像往常一样使用urllib3。

我不明白这意味着什么?我需要修补一些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()
>>> 

1 个答案:

答案 0 :(得分:0)

我知道您使用的是使用urllib3的OpenStack。所以,是的,如果你想走那条大道并“修补”OpenStack,那么找一些像import .*urllib3.*from urllib3 import .*这样的东西,并在每个实例之后添加它们指示你添加的两行。