2

I'm wrote a python script to download the content of a website and it is working perfectly fine when i execute it on a linux machine, but not on windows (and it needs to be executed on windows).

Here is the code generating the error :

   import requests
   c = requests.Session()
   url = 'https://ted.jeancoutu.com/action/login'
   c.get(url)

Here is the error message i get when i execute the code on a windows machine:

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 348, in ssl_wrap_socket
    cnx.do_handshake()
  File "C:\Python34\lib\site-packages\OpenSSL\SSL.py", line 1443, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "C:\Python34\lib\site-packages\OpenSSL\SSL.py", line 1191, in _raise_ssl_error
    _raise_current_error()
  File "C:\Python34\lib\site-packages\OpenSSL\_util.py", line 48, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 578, in urlopen
    chunked=chunked)
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 351, in _make_request
    self._validate_conn(conn)
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 814, in _validate_conn
    conn.connect()
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connection.py", line 289, in connect
    ssl_version=resolved_ssl_version)
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 355, in ssl_wrap_socket
    raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\requests\adapters.py", line 403, in send
    timeout=timeout
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 604, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\site-packages\requests\sessions.py", line 487, in get
    return self.request('GET', url, **kwargs)
  File "C:\Python34\lib\site-packages\requests\sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python34\lib\site-packages\requests\sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python34\lib\site-packages\requests\adapters.py", line 477, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",)

I couldn't find a solution to this problem. I tried many suggestions i found online but nothing worked. I installed pyOpenSSL, ndg-httpsclient and pyasn1 with no result. I also upgraded ssl but still nothing.

Thank you for your suggestions

1 Answers1

1

The site ted.jeancoutu.com only supports RC4-SHA and RC4-MD5 ciphers (see SSLLabs report. RC4 ciphers are considered insecure and therefore got removed from the default cipher set in requests in version 2.5.2 in 02/2015. You are probably using an older version of requests on Linux so it still works, but it fails with the newer version on Windows.

See https://stackoverflow.com/a/32651967/3081018 for how to work around the problem by enabling the insecure cipher.

Community
  • 1
  • 1
Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172