title: OSX Python SSL handshake error
body: <p>I've read this error in stackoverflow many times but none of the solutions in those worked for me.</p>
  
  <p>OSX El Capitan 10.11.3, Python 2.7.10, OpenSSL 0.9.8zg</p>
  
  <ul>
  <li>pip is updated with the latest version</li>
  <li>openssl installed with brew</li>
  <li><p>Following piece is run as per recommended <a href="https://github.com/kennethreitz/requests/issues/2022#issuecomment-75506581" rel="nofollow">here</a>:</p>
  
  <pre><code>env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install requests[security] urllib3
  </code></pre></li>
  </ul>
  
  <p>I still receive the following error message when I run following 4 lines on python:</p>
  
  <pre><code>&gt;&gt;&gt; import requests
  &gt;&gt;&gt; s = requests.Session()
  &gt;&gt;&gt; url = "https://www.tastekid.com/api/similar?q=pulp+fiction"
  &gt;&gt;&gt; requests.get(url)
  
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/Library/Python/2.7/site-packages/requests/api.py", line 67, in get
      return request('get', url, params=params, **kwargs)
    File "/Library/Python/2.7/site-packages/requests/api.py", line 53, in request
      return session.request(method=method, url=url, **kwargs)
    File "/Library/Python/2.7/site-packages/requests/sessions.py", line 468, in request
      resp = self.send(prep, **send_kwargs)
    File "/Library/Python/2.7/site-packages/requests/sessions.py", line 576, in send
      r = adapter.send(request, **kwargs)
    File "/Library/Python/2.7/site-packages/requests/adapters.py", line 447, in send
      raise SSLError(e, request=request)
  requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",)
  </code></pre>
  
  <p>Could it be cryptography error? I also tried installing cryptography module with following code, with failure:</p>
  
  <pre><code>$ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography
  Collecting cryptography
    Using cached cryptography-1.3.1-cp27-cp27m-macosx_10_10_intel.whl
  Collecting setuptools&gt;=11.3 (from cryptography)
    Using cached setuptools-20.10.1-py2.py3-none-any.whl
  Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography)
  Collecting ipaddress (from cryptography)
    Using cached ipaddress-1.0.16-py27-none-any.whl
  Requirement already satisfied (use --upgrade to upgrade): pyasn1&gt;=0.1.8 in /Library/Python/2.7/site-packages (from cryptography)
  Requirement already satisfied (use --upgrade to upgrade): six&gt;=1.4.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from cryptography)
  Collecting idna&gt;=2.0 (from cryptography)
    Using cached idna-2.1-py2.py3-none-any.whl
  Requirement already satisfied (use --upgrade to upgrade): cffi&gt;=1.4.1 in /Library/Python/2.7/site-packages (from cryptography)
  Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi&gt;=1.4.1-&gt;cryptography)
  Installing collected packages: setuptools, ipaddress, idna, cryptography
    Found existing installation: setuptools 1.1.6
      Uninstalling setuptools-1.1.6:
  Exception:
  Traceback (most recent call last):
    File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 209, in main
      status = self.run(options, args)
    File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
      prefix=options.prefix_path,
    File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 726, in install
      requirement.uninstall(auto_confirm=True)
    File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 746, in uninstall
      paths_to_remove.remove(auto_confirm)
    File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
      renames(path, new_path)
    File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
      shutil.move(old, new)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
      copytree(src, real_dst, symlinks=True)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
      raise Error, errors
  Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/var/folders/d9/75cfznt17cjc124j3stq3qc40000gn/T/pip-sbS3mg-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I upgraded my OpenSSL to 1.0.2 now. Still receiving the same error. Here's the cipher list with "ECDHE" (apparently the site server supports those ciphers):</p>
  
  <pre><code>$ openssl ciphers -v 'ECDHE'
  ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH     Au=RSA  Enc=AESGCM(256) Mac=AEAD
  ECDHE-ECDSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AESGCM(256) Mac=AEAD
  ECDHE-RSA-AES256-SHA384 TLSv1.2 Kx=ECDH     Au=RSA  Enc=AES(256)  Mac=SHA384
  ECDHE-ECDSA-AES256-SHA384 TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AES(256)  Mac=SHA384
  ECDHE-RSA-AES256-SHA    SSLv3 Kx=ECDH     Au=RSA  Enc=AES(256)  Mac=SHA1
  ECDHE-ECDSA-AES256-SHA  SSLv3 Kx=ECDH     Au=ECDSA Enc=AES(256)  Mac=SHA1
  ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 Kx=ECDH     Au=RSA  Enc=AESGCM(128) Mac=AEAD
  ECDHE-ECDSA-AES128-GCM-SHA256 TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AESGCM(128) Mac=AEAD
  ECDHE-RSA-AES128-SHA256 TLSv1.2 Kx=ECDH     Au=RSA  Enc=AES(128)  Mac=SHA256
  ECDHE-ECDSA-AES128-SHA256 TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AES(128)  Mac=SHA256
  ECDHE-RSA-AES128-SHA    SSLv3 Kx=ECDH     Au=RSA  Enc=AES(128)  Mac=SHA1
  ECDHE-ECDSA-AES128-SHA  SSLv3 Kx=ECDH     Au=ECDSA Enc=AES(128)  Mac=SHA1
  ECDHE-RSA-RC4-SHA       SSLv3 Kx=ECDH     Au=RSA  Enc=RC4(128)  Mac=SHA1
  ECDHE-ECDSA-RC4-SHA     SSLv3 Kx=ECDH     Au=ECDSA Enc=RC4(128)  Mac=SHA1
  ECDHE-RSA-DES-CBC3-SHA  SSLv3 Kx=ECDH     Au=RSA  Enc=3DES(168) Mac=SHA1
  ECDHE-ECDSA-DES-CBC3-SHA SSLv3 Kx=ECDH     Au=ECDSA Enc=3DES(168) Mac=SHA1
  ECDHE-RSA-NULL-SHA      SSLv3 Kx=ECDH     Au=RSA  Enc=None      Mac=SHA1
  ECDHE-ECDSA-NULL-SHA    SSLv3 Kx=ECDH     Au=ECDSA Enc=None      Mac=SHA1
  </code></pre>