InsecurePlatformWarning when creating a Docker image

I get this warning when creating a Docker image:

/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. 

Several sources (for example, InsecurePlatformWarning: the true SSLContext object is not available. This does not allow urllib3 to configure SSL correctly ) that pip install pyopenssl ndg-httpsclient pyasn1 will fix this problem. But I get a warning as soon as pip tries to install pyopenssl.

Here is my Docker file:

 FROM ubuntu:14.04 # Install packages RUN apt-get update && apt-get install -y \ git \ libmysqlclient-dev \ mysql-server \ nginx \ python-dev \ python-mysqldb \ python-setuptools \ supervisor \ vim RUN easy_install pip # Handle urllib3 InsecurePlatformWarning RUN apt-get install -y libffi-dev libssl-dev RUN pip install pyopenssl ndg-httpsclient pyasn1 # ...more 
+7
python docker pip ubuntu urllib3
source share
1 answer

This seems to be expected when pip starts: http://github.com/pypa/pip/issues/2681 , but as you install pyopenssl ndg-httpsclient pyasn1 you will not get a warning when using python requests.

For example, if I create this Docker file:

 FROM ubuntu:14.04 # Install packages RUN apt-get update && apt-get install -y \ git \ libmysqlclient-dev \ mysql-server \ nginx \ python-dev \ python-mysqldb \ python-setuptools \ supervisor \ vim RUN easy_install pip RUN pip install requests 

and then run it inside the container:

 root@b2759f79f947 :/# python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> url = "https://www.digicert.com/" >>> r = requests.get(url) /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:100: 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 

As you can see, I get a warning. But if I add these lines to the Dockerfile:

 RUN apt-get install -y libffi-dev libssl-dev RUN pip install pyopenssl ndg-httpsclient pyasn1 

and run the same python commands, I no longer get the warning.

If you really do not want a warning when setting pyopenssl, you can set the environment variable: PYTHONWARNINGS="ignore:a true SSLContext object" , as suggested here: https://github.com/pypa/pip/pull/3109

Your Dockerfile will look like this:

 FROM ubuntu:14.04 # Install packages RUN apt-get update && apt-get install -y \ git \ libmysqlclient-dev \ mysql-server \ nginx \ python-dev \ python-mysqldb \ python-setuptools \ supervisor \ vim RUN easy_install pip # Handle urllib3 InsecurePlatformWarning RUN apt-get install -y libffi-dev libssl-dev ENV PYTHONWARNINGS="ignore:a true SSLContext object" RUN pip install pyopenssl ndg-httpsclient pyasn1 

Another solution would be to upgrade python to version 2.7.9

+2
source share

All Articles