UniFi Device tracker error: SSLV3_ALERT_UNEXPECTED_MESSAGE

My unifi device tracker is really unstable. I get this error message all the time. And I have turned off verify_ssl setting in the configuration. Any ideas?

17-03-27 14:06:03 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform unifi
Traceback (most recent call last):
  File "/srv/hass/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/hass/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/srv/hass/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/srv/hass/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
  File "/srv/hass/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_UNEXPECTED_MESSAGE] sslv3 alert unexpected message (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/lib/python3.5/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/srv/hass/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 630, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [SSL: SSLV3_ALERT_UNEXPECTED_MESSAGE] sslv3 alert unexpected message (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 152, in async_setup_platform
    None, platform.get_scanner, hass, {DOMAIN: p_config})
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/lib/python3.5/site-packages/homeassistant/components/device_tracker/unifi.py", line 53, in get_scanner
    site_id=site_id, ssl_verify=verify_ssl)
  File "/home/hass/.homeassistant/deps/pyunifi/controller.py", line 65, in __init__
    self._login(version)
  File "/home/hass/.homeassistant/deps/pyunifi/controller.py", line 123, in _login
    r = self.session.post(login_url, params)
  File "/srv/hass/lib/python3.5/site-packages/requests/sessions.py", line 535, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/srv/hass/lib/python3.5/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/lib/python3.5/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/srv/hass/lib/python3.5/site-packages/requests/adapters.py", line 497, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: SSLV3_ALERT_UNEXPECTED_MESSAGE] sslv3 alert unexpected message (_ssl.c:645)

I think that adding this ( verify_ssl: False ) to your configuration will fix your problem.

1 Like

I’ve already tried that.

For MFI i needed to add the following to the MFI app in macOS

In mfi.app\resources\conf\server.xml
You’ll see two SSL connector elements in that file, each needs an attribute added similar to:

ciphers=“TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA”

I don’t run mac os and I don’t use MFI, just “regular” unifi with two unifi AP’s

I tried to turn ON verify_ssl and I got the “correct” error: SSL: CERTIFICATE_VERIFY_FAILED

I turned it back off and I got the “SSL: SSLV3_ALERT_UNEXPECTED_MESSAGE” back.

I can confirm this! Also using UniFi and have this kind of errors. Additional information: I use UniFi in a docker container.