mdeff / fma

FMA: A Dataset For Music Analysis
https://arxiv.org/abs/1612.01840
MIT License
2.2k stars 432 forks source link

Can't verify SSL certificate for small dataset #24

Closed andimarafioti closed 4 years ago

andimarafioti commented 6 years ago

When I try to download the small dataset (haven't tried with the others) with a script I get a SSL certification verification error.

The error can be reproduced in this minimal form:

import urllib.request

with urllib.request.urlopen('https://os.unil.cloud.switch.ch/fma/fma_small.zip') as response:
    pass

My traceback is:

---------------------------------------------------------------------------
SSLError                                  Traceback (most recent call last)
c:\users\amarafioti\appdata\local\programs\python\python36\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
   1317                 h.request(req.get_method(), req.selector, req.data, headers,
-> 1318                           encode_chunked=req.has_header('Transfer-encoding'))
   1319             except OSError as err: # timeout error

c:\users\amarafioti\appdata\local\programs\python\python36\lib\http\client.py in request(self, method, url, body, headers, encode_chunked)
   1238         """Send a complete request to the server."""
-> 1239         self._send_request(method, url, body, headers, encode_chunked)
   1240

c:\users\amarafioti\appdata\local\programs\python\python36\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1284             body = _encode(body, 'body')
-> 1285         self.endheaders(body, encode_chunked=encode_chunked)
   1286

c:\users\amarafioti\appdata\local\programs\python\python36\lib\http\client.py in endheaders(self, message_body, encode_chunked)
   1233             raise CannotSendHeader()
-> 1234         self._send_output(message_body, encode_chunked=encode_chunked)
   1235

c:\users\amarafioti\appdata\local\programs\python\python36\lib\http\client.py in _send_output(self, message_body, encode_chunked)
   1025         del self._buffer[:]
-> 1026         self.send(msg)
   1027

c:\users\amarafioti\appdata\local\programs\python\python36\lib\http\client.py in send(self, data)
    963             if self.auto_open:
--> 964                 self.connect()
    965             else:

c:\users\amarafioti\appdata\local\programs\python\python36\lib\http\client.py in connect(self)
   1399             self.sock = self._context.wrap_socket(self.sock,
-> 1400                                                   server_hostname=server_hostname)
   1401             if not self._context.check_hostname and self._check_hostname:

c:\users\amarafioti\appdata\local\programs\python\python36\lib\ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    400                          server_hostname=server_hostname,
--> 401                          _context=self, _session=session)
    402

c:\users\amarafioti\appdata\local\programs\python\python36\lib\ssl.py in __init__(self, sock, keyfile, certfile, server_side, cert_reqs, ssl_version, ca_certs, do_handshake_on_connect, family, type, proto, fileno, suppress_ragged_eofs, npn_protocols, ciphers, server_hostname, _context, _session)
    807                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
--> 808                     self.do_handshake()
    809

c:\users\amarafioti\appdata\local\programs\python\python36\lib\ssl.py in do_handshake(self, block)
   1060                 self.settimeout(None)
-> 1061             self._sslobj.do_handshake()
   1062         finally:

c:\users\amarafioti\appdata\local\programs\python\python36\lib\ssl.py in do_handshake(self)
    682         """Start the SSL/TLS handshake."""
--> 683         self._sslobj.do_handshake()
    684         if self.context.check_hostname:

SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
<ipython-input-10-9d04e6e06fb8> in <module>()
----> 1 with urllib.request.urlopen('https://os.unil.cloud.switch.ch/fma/fma_small.zip') as response:
      2     pass

c:\users\amarafioti\appdata\local\programs\python\python36\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    221     else:
    222         opener = _opener
--> 223     return opener.open(url, data, timeout)
    224
    225 def install_opener(opener):

c:\users\amarafioti\appdata\local\programs\python\python36\lib\urllib\request.py in open(self, fullurl, data, timeout)
    524             req = meth(req)
    525
--> 526         response = self._open(req, data)
    527
    528         # post-process response

c:\users\amarafioti\appdata\local\programs\python\python36\lib\urllib\request.py in _open(self, req, data)
    542         protocol = req.type
    543         result = self._call_chain(self.handle_open, protocol, protocol +
--> 544                                   '_open', req)
    545         if result:
    546             return result

c:\users\amarafioti\appdata\local\programs\python\python36\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
    502         for handler in handlers:
    503             func = getattr(handler, meth_name)
--> 504             result = func(*args)
    505             if result is not None:
    506                 return result

c:\users\amarafioti\appdata\local\programs\python\python36\lib\urllib\request.py in https_open(self, req)
   1359         def https_open(self, req):
   1360             return self.do_open(http.client.HTTPSConnection, req,
-> 1361                 context=self._context, check_hostname=self._check_hostname)
   1362
   1363         https_request = AbstractHTTPHandler.do_request_

c:\users\amarafioti\appdata\local\programs\python\python36\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
   1318                           encode_chunked=req.has_header('Transfer-encoding'))
   1319             except OSError as err: # timeout error
-> 1320                 raise URLError(err)
   1321             r = h.getresponse()
   1322         except:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)>

I found a workaround passing context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) as an argument to the urlopen method but I thought this is something you may want to be aware of.

mdeff commented 4 years ago

Thanks for reporting! I can't reproduce. The issue may have been fixed by the hosting provider. Please reopen if that's still an issue.