Ubuntu 16.04 Python3 SSLV3_ALERT_HANDSHAKE_FAILURE

Using:
Python 3.5.2 
Ubuntu 16.04.01
OpenSSL 1.0.2g  1 Mar 2016

pip freeze:

alabaster==0.7.9
amqp==2.1.4
antigate==1.4.0
anyjson==0.3.3
Babel==2.3.4
beautifulsoup4==4.5.3
billiard==3.5.0.2
celery==4.0.2
celery-with-redis==3.0
certifi==2016.9.26
cffi==1.9.1
configparser==3.5.0
cryptography==1.7.1
Django==1.10.5
django-docs==0.2.1
djangorestframework==3.5.3
docutils==0.13.1
epydoc==3.0.1
flower==0.9.1
future==0.16.0
gunicorn==19.6.0
idna==2.2
imagesize==0.7.1
Jinja2==2.9.4
kombu==4.0.2
lxml==3.7.2
MarkupSafe==0.23
miette==1.3
ndg-httpsclient==0.4.2
nose==1.3.7
olefile==0.44
ordereddict==1.1
Pillow==4.0.0
probableparsing==0.0.1
psycopg2==2.6.1
pyasn1==0.1.9
pycparser==2.17
Pygments==2.1.3
pyPdf==1.13
python-crfsuite==0.9.1
python-dateutil==2.6.0
pytz==2016.10
redis==2.10.5
reportlab==3.3.0
requests==2.12.4
selenium==2.52.0
six==1.10.0
snowballstemmer==1.2.1
South==1.0.2
Sphinx==1.5.1
tornado==4.2
Unidecode==0.4.20
urllib3==1.19.1
usaddress==0.5.9
vine==1.1.3
xlrd==1.0.0
xmltodict==0.10.2
xvfbwrapper==0.2.9

I tried to track this down from other issues but none of them seemed to answer the problem for my setup. Here is the console steps with error output:

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.get("https://webapps.kdads.ks.gov", verify=False)
Traceback (most recent call last):
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 350, in _make_request
    self._validate_conn(conn)
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 835, in _validate_conn
    conn.connect()
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 323, in connect
    ssl_context=context)
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/packages/urllib3/util/ssl_.py", line 324, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.5/ssl.py", line 377, in wrap_socket
    _context=self)
  File "/usr/lib/python3.5/ssl.py", line 752, in __init__
    self.do_handshake()
  File "/usr/lib/python3.5/ssl.py", line 988, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.5/ssl.py", line 633, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 624, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/datadev/.envs/scraping/lib/python3.5/site-packages/requests/adapters.py", line 497, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:645)

I should note we had the same issue with OSX but assumed it was related to our setup with using the built in (outdated) version of OpenSSL. I'm hoping someone will have an easy fix for this that I am just missing.

The problem here is that the only cipher suite the server supports is 3DES-based, and newer versions of Requests do not allow 3DES because it is insecure for large data transfers.

If you know the server operators or can contact them, you should ask them to improve their TLS usage. In the meantime, you can resolve this by mounting a custom transport adapter for that specific hostname, as shown by [this answer](https://github.com/kennethreitz/requests/issues/3774#issuecomment-267871876).

@Lukasa Hmm, I was hoping that would work. I ran the following and got the same response.

import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
from requests.packages.urllib3.util.ssl_ import create_urllib3_context
CIPHERS = (
    'ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:'
    'DH+HIGH:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES:!aNULL:'
    '!eNULL:!MD5'
)
baseurl='https://webapps.kdads.ks.gov/LSOBP18'
class DESAdapter(HTTPAdapter):
    def init_poolmanager(self, connections, maxsize, block=False,*args, **kwargs):
        context = create_urllib3_context(ciphers=CIPHERS)
        kwargs['ssl_context'] = context
        self.poolmanager = PoolManager(num_pools=connections,
                                       maxsize=maxsize,
                                       block=block,
                                       *args, **kwargs)
s=requests.Session()
s.mount('https://10.192.8.89', DESAdapter())
s.get(baseurl, verify=False)

You need to change the mount line to mount at https://webapps.kdads.ks.gov

Thanks, sorry for that.