python - Troubleshooting "ssl certificate verify failed" error -


on windows vista sp2 + python 2.7.10 can connect https://www.python.org, not https://codereview.appspot.com

the script:

host1 = 'https://www.python.org' host2 = 'https://codereview.appspot.com'  import urllib2 print host1 urllib2.urlopen(host1) print host2 urllib2.urlopen(host2) 

and output:

e:\>py test.py https://www.python.org https://codereview.appspot.com traceback (most recent call last):   file "test.py", line 9, in <module>     urllib2.urlopen(host2)   file "c:\python27\lib\urllib2.py", line 158, in urlopen     return opener.open(url, data, timeout)   file "c:\python27\lib\urllib2.py", line 435, in open     response = self._open(req, data)   file "c:\python27\lib\urllib2.py", line 453, in _open     '_open', req)   file "c:\python27\lib\urllib2.py", line 413, in _call_chain     result = func(*args)   file "c:\python27\lib\urllib2.py", line 1244, in https_open     context=self._context)   file "c:\python27\lib\urllib2.py", line 1201, in do_open     raise urlerror(err) urllib2.urlerror: <urlopen error [ssl: certificate_verify_failed] certificate verify failed (_ssl.c:590)> 

how can troubleshoot, wrong https://codereview.appspot.com/ ?

my guess is related alternative chain handling in openssl, described in detail in python urllib2 ssl error. although python uses windows ca store trusted root certificates validation of trust chain done within openssl.

according "python 2.7.10 released" python 2.7.10 on windows includes openssl 1.0.2a fixes regarding alternative chains done in 1.0.2b (and had fixed fast afterwards because contained serious security bug).

if @ ssllabs report codereview.appspot.com can see there multiple trust chains causes problem. contrary python.org has single trust chain.

to work around problem might necessary use own root ca store must contain certificate "/c=us/o=equifax/ou=equifax secure certificate authority" verify codereview.appspot.com correctly. certificate can found here , can give cafile parameter urllib2.urlopen.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -