Coder Perfect

InsecurePlatform There is no genuine SSLContext object accessible. This stops urllib3 from properly configuring SSL. [duplicate]


I attempted to execute a REST GET using python requests and received an error.

Code snip:

import requests
header = {'Authorization': 'Bearer...'}
url = az_base_url + az_subscription_id + '/resourcegroups/Default-Networking/resources?' + az_api_version
r = requests.get(url, headers=header)


          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

Python 2.7.3 is the version I’m using. I attempted to install urllib3 and requests[security] as suggested in another thread, but I received the same issue.

I’m wondering if anyone has any suggestions?

Asked by user4525298

Solution #1

The documents provide a good indication of what is needed, however requests allow us to skip a few steps:

You only need to install the security package extras (thanks @admdrew for pointing it out)

$ pip install requests[security]

Alternatively, you can install them directly:

$ pip install pyopenssl ndg-httpsclient pyasn1

Requests will then inject pyopenssl into urllib3 automatically.

If you’re using Ubuntu, you could have difficulties installing pyopenssl because it requires the following dependencies:

$ apt-get install libffi-dev libssl-dev

Answered by nathan-m

Solution #2

If you are unable to upgrade to Python 2.7.9 and would like to disable warnings,

You can downgrade your’requests’ version to 2.5.3 by following these steps:

pip install requests==2.5.3

In 2.6.0, a bugfix disclosure / warning was added.

Answered by raittes

Post is based on