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?

3 Answers 3

14

The fix for me was the following:

sudo apt-get purge python-openssl
sudo pip install pyopenssl
Sign up to request clarification or add additional context in comments.

1 Comment

I needed to sudo apt-get install libffi-dev before installing pyopenssl
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

1 Comment

Thanks. Upgrading pip was what was needed in my case.
2

On RedHat:

sudo yum remove pyOpenSSL
sudo pip install pyopenssl

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.