13

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?

Community
  • 1
  • 1
Zags
  • 31,395
  • 12
  • 87
  • 123

3 Answers3

14

The fix for me was the following:

sudo apt-get purge python-openssl
sudo pip install pyopenssl
Zags
  • 31,395
  • 12
  • 87
  • 123
3

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
Ben McCann
  • 17,641
  • 23
  • 79
  • 99
Andrew
  • 518
  • 5
  • 8
2

On RedHat:

sudo yum remove pyOpenSSL
sudo pip install pyopenssl
Ben McCann
  • 17,641
  • 23
  • 79
  • 99