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:

Only the security package extras must be installed (thanks to @admdrew for pointing this up).

$ pip install requests[security]

Alternatively, you can install them directly:

$ pip install pyopenssl ndg-httpsclient pyasn1

Requests will then automatically inject pyopenssl into urllib3

If you’re on ubuntu, you may run into trouble installing pyopenssl, you’ll need these 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