13
votes

In python, on a Ubuntu server, I am trying to get the requests library to make https requests, like so:

import requests
requests.post("https://example.com")

At first, I got the following:

/usr/local/lib/python2.7/dist-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.

After following the advice in this question: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately, I have now upgraded my warning to the following error:

AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'

How do I fix this?

3

3 Answers

14
votes

The fix for me was the following:

sudo apt-get purge python-openssl
sudo pip install pyopenssl
3
votes

This was able to get the python working on Ubuntu 12.04.3 LTS for me.

sudo apt-get install python-dev python-pip build-essential libffi-dev
sudo -H pip install --upgrade pip setuptools && sudo -H pip install --upgrade pyopenssl
2
votes

On RedHat:

sudo yum remove pyOpenSSL
sudo pip install pyopenssl