This appears to be a Windows certificate store inconsistency. httplib - which is called internally by urllib2 - has recently been changed without checking the server certificate, so that by default it checks the server certificate. Therefore, you will encounter this problem in any python script that is based on urllib , httplib and works in your user profile.
However, something seems very wrong in your Windows certificate store. httplib does not work for you when trying to list certificates for the CA certification authority named certificate stores (displayed as Intermediate Certification Authorities in certmgr.msc ), but for ROOT , which is the usual trusted root certificate store (see comments for the question). Therefore, I suggest checking all certificates in certmgr:intermediate certificate authorities for recently added certificates and / or Windows log for common errors. What happens in your case is that urllib2 internally calls httplib , which then tries to set the default ssl context with a forced certificate validation, and as part of this lists the trusted certificate bindings of your system by calling ssl.enum_certificates , This function is implemented in C as _ssl_enum_certificates_impl and internally calls WINAPIs CertOpenSystemStore and CertEnumCertificatesInStore . For the CA certificate store location, it simply fails in one of two winapi access denied calls.
If you want to continue debugging, you can also try to manually call WINAPI:CertOpenSystemStore with LPTCSTR::'CA' as an argument and try to debug it from this side, try other Windows certificate management tools and / or call Microsoft support for support.
There are also signs that others had similar problems interacting with this api call, see google: access denied CertOpenSystemStore
If you just want it to work without fixing the root cause, you could just try using the following workaround, which temporarily fixes _windows_cert_stores , so as not to turn on the damaged CA certstore or completely disable the trust-anchor logic loading. (all other ssl.SSLContext calls will be fixed in the current process)
Note that effectively disables server certificate verification.
ssl.SSLContext._windows_cert_stores = ("ROOT",) # patch windows_cert_stores default to only include "ROOT" as "CA" is broken for you. #ssl.SSLContext.load_default_certs = lambda s,x:None # alternative, fully NOP load_default_certs to do nothing instead. ctx = ssl.create_default_context() # create new sslcontext, not veryfing any certificates, hostnames. ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE hdr = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'} req = Request('https://' + url, headers=hdr) x = urlopen( req , context=ctx).read() ssl.SSLContext._windows_cert_stores = ("ROOT","CA") # UNDO PATCH
I hope this information helps you solve the problem. good luck.