3

I'm doing practice with the google-python course. However, I got problem with the urllib. Here is the simplified code:

import urllib
url = 'http://www.google.com'
ufile=urllib.urlopen(url)

This code actually works, but if I change the url to some other ones, like:

url = 'https://developers.google.com/edu/python/utilities#exceptions'

It will raise the error:

IOError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED]   certificate verify failed (_ssl.c:590)

The full error information is as follows:

Traceback (most recent call last):
  File "practice2.py", line 4, in <module>
    ufile=urllib.urlopen(url)
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/urllib.py", line 87, in urlopen
    return opener.open(url)
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/urllib.py", line 443, in open_https
    h.endheaders(data)
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/httplib.py", line 893, in _send_output
    self.send(msg)
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/httplib.py", line 855, in send
    self.connect()
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/httplib.py", line 1274, in connect
    server_hostname=server_hostname)
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/ssl.py", line 352, in wrap_socket
    _context=self)
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/ssl.py", line 579, in __init__
    self.do_handshake()
  File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

Thank you very much to read this!

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
jren
  • 33
  • 1
  • 1
  • 5

2 Answers2

2

Python is much more strict with ssl currently than it has been before. You can temporarily bypass the ssl verification. Take a look at this post. Of course this might not be a permanent solution but if You have no access to configure developers.google.com certs, that might be the best you can do.

Community
  • 1
  • 1
Ance
  • 146
  • 8
  • Thank you. It works! (though not sure how it works, as I know little about ssl so far...) – jren Mar 21 '16 at 08:23
0

1 check the SSL version

2 to ensure that the bottom of the socket module is to support the SSL compile mode, that is, when the SSL compiler option is open.

3 port error, check it

M.r
  • 13
  • 3
  • Thank you very much for your quick reply. I know little about SSL and socket, so if you don't mind, could you briefly show me how to do this or do you have any recommended reading for these? Thanks again. – jren Mar 21 '16 at 08:17
  • Um,I'm newbie.I just had a look at this problem.I'm sorry ,I can't give you some useful advice. – M.r Mar 21 '16 at 08:37