Skip to content

Instantly share code, notes, and snippets.

View n1mh's full-sized avatar

Diego Martínez Castañeda n1mh

View GitHub Profile
@n1mh
n1mh / gist:bcb67cd2203a2d261ac0195f1dafacf0
Created March 1, 2017 13:21 — forked from iLoveTux/gist:c0c6216dca943876da6d
permit insecure connections with urllib2.urlopen in python 2.7.x >= 2.7.9
# Because migrating to python 2.7.9 requires me to update my code (or ask my clients to add cafiles to their trust store
# [which some people don't know how to do]), I found a way to explicitly allow insecure connections (ie. without hostname
# verification) using urllib2.urlopen()
#
# This gist basically involves creating an ssl.SSLContext() with some options which disable hostname verification
# This allows you to, for instance, add a parameter to a function which disables hostname verification.
import ssl
import urllib2
import logging