home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.97k stars 30.52k forks source link

Problem with connecting to Home Assistant cloud #16469

Closed tsrubar closed 6 years ago

tsrubar commented 6 years ago

Home Assistant release with the issue:

0.77.3

Last working Home Assistant release (if known): ???

Operating environment (Hass.io/Docker/Windows/etc.):

RPi 3B with Hassbian

Component/platform:

cloud

Description of problem: After entering cright credentials in Configuration>Home Assistant Cloud, I get an "Unknown error" red message right above "Email" line instead of logging in.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

cloud:

Traceback (if applicable):

Thu Sep 06 2018 23:50:01 GMT+0200 (Central European Summer Time)

Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 390, in start
    resp = await self._request_handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_app.py", line 352, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_middlewares.py", line 106, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/view.py", line 113, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/http_api.py", line 45, in error_handler
    result = await handler(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/http_api.py", line 102, in post
    data['password'])
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, 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/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/auth_api.py", line 91, in login
    cognito = _authenticate(cloud, email, password)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/auth_api.py", line 126, in _authenticate
    cognito.authenticate(password=password)
  File "/srv/homeassistant/lib/python3.5/site-packages/warrant/__init__.py", line 383, in authenticate
    self.verify_token(tokens['AuthenticationResult']['IdToken'],'id_token','id')
  File "/srv/homeassistant/lib/python3.5/site-packages/warrant/__init__.py", line 197, in verify_token
    kid = jwt.get_unverified_header(token).get('kid')
AttributeError: module 'jose.jwt' has no attribute 'get_unverified_header'

Additional information:

tsrubar commented 6 years ago

There are more people with this issue: https://community.home-assistant.io/t/help-components-cloud-auth-api-py-error/40435 https://community.home-assistant.io/t/issues-while-login-to-cloud/51556

balloob commented 6 years ago

Can you clear your config/deps folder? If that doesn't help, please list the integrations that you use, as one might install incorrect dependency

tsrubar commented 6 years ago

Hi @balloob and let me first thank you for your response. My deps folder is already empty. Integrations I use away from standard pre-configured are:

I think there isnt anything special, that could lead to breaking of cloud component.

EDIT: I wanted to include ls -lah /srv/homeassistant/lib/python3.5/site-packages/ but I just flooded my post as hell

pvizeli commented 6 years ago

Please post the output of:

pip3 freeze | grep JWT
pip3 freeze | grep jwt
pip3 freeze | grep jose
tsrubar commented 6 years ago
(homeassistant) homeassistant@hassbian:~/.homeassistant $ pip3 freeze | grep JWT
PyJWT==1.6.4
(homeassistant) homeassistant@hassbian:~/.homeassistant $ pip3 freeze | grep jwt
(homeassistant) homeassistant@hassbian:~/.homeassistant $ pip3 freeze | grep jose
python-jose==0.5.6
python-jose-cryptodome==1.3.2
tsrubar commented 6 years ago

So far, I have tried this, but didnt help:

pip install -U pycrypto pycryptodome  pycryptodomex PyJWT     
pip3 uninstall cryptography pycrypto pycryptodome pycryptodomex cffi
(yes to all)
python3 -m pip install --no-cache-dir cryptography
python3 -m pip install --no-cache-dir cffi
python3 -m pip install --no-cache-dir PyJWT
python3 -m pip install --upgrade homeassistant
tsrubar commented 6 years ago
pip3 freeze
aiohttp==3.4.0
aiohttp-cors==0.7.0
appdirs==1.4.3
asn1crypto==0.24.0
astral==1.6.1
async-timeout==3.0.0
attrs==18.1.0
bcrypt==3.1.4
beautifulsoup4==4.6.3
boto3==1.5.22
botocore==1.8.36
certifi==2018.8.24
cffi==1.11.5
chardet==3.0.4
colorlog==3.1.2
ConfigArgParse==0.11.0
crypto==1.4.1
cryptography==2.3.1
distro==1.3.0
docutils==0.14
ecdsa==0.13
enum-compat==0.0.2
envs==1.2.4
flake8==3.5.0
future==0.16.0
fuzzywuzzy==0.16.0
googlemaps==2.5.1
gTTS-token==1.1.1
hangups==0.4.5
holidays==0.9.6
home-assistant-frontend==20180903.0
homeassistant==0.77.3
http-ece==1.0.5
idna==2.6
idna-ssl==1.0.1
Jinja2==2.10
jmespath==0.9.3
MarkupSafe==1.0
mccabe==0.6.1
MechanicalSoup==0.6.0
multidict==4.1.0
mutagen==1.41.0
Naked==0.1.31
netdisco==2.0.0
netifaces==0.10.6
paho-mqtt==1.3.1
pkg-resources==0.0.0
protobuf==3.1.0.post1
py-vapid==1.4.0
PyChromecast==2.1.0
pycodestyle==2.3.1
pycparser==2.18
PyCRC==1.21
pycrypto==2.6.1
pycryptodome==3.6.6
pycryptodomex==3.6.6
pyelliptic==1.5.8
pyflakes==1.6.0
PyJWT==1.6.4
pyotp==2.2.6
PyQRCode==1.2.1
python-dateutil==2.7.2
python-jose==0.5.6
python-jose-cryptodome==1.3.2
pytz==2018.4
pyunifi==2.13
pywebpush==1.6.0
PyYAML==3.13
readlike==0.1.2
ReParser==1.4.3
requests==2.19.1
s3transfer==0.1.12
samsungctl==0.7.1
shellescape==3.4.1
six==1.11.0
SQLAlchemy==1.2.10
transmissionrpc==0.11
typing==3.6.4
ua-parser==0.7.3
urllib3==1.22
urwid==1.3.1
user-agents==1.1.0
voluptuous==0.11.5
voluptuous-serialize==2.0.0
wakeonlan==1.0.0
warrant==0.6.1
websocket-client==0.47.0
xmltodict==0.11.0
yarl==1.1.1
zeroconf==0.20.0
pvizeli commented 6 years ago

Please try: pip3 uninstall python-jose

tsrubar commented 6 years ago

I tried to login after uninstalling python-jose, but got same message with following error: Log Details (ERROR) Fri Sep 07 2018 20:33:44 GMT+0200 (Central European Summer Time)

Error handling request Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 390, in start resp = await self._request_handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_app.py", line 352, in _handle resp = await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_middlewares.py", line 106, in impl return await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware return await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware return await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware return await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware return await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware return await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware return await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware return await handler(request) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/view.py", line 113, in handle result = await result File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/http_api.py", line 45, in error_handler result = await handler(view, request, *args, kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper result = await method(view, request, *args, *kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/http_api.py", line 102, in post data['password']) File "/usr/lib/python3.5/asyncio/futures.py", line 380, in iter yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, 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/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/auth_api.py", line 91, in login cognito = _authenticate(cloud, email, password) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/cloud/auth_api.py", line 119, in _authenticate from warrant.exceptions import ForceChangePasswordException File "/srv/homeassistant/lib/python3.5/site-packages/warrant/init.py", line 8, in from jose import jwt, JWTError ImportError: cannot import name 'jwt'

pvizeli commented 6 years ago

Can you also python-jose-cryptodome and warrant?

dynasticorpheus commented 6 years ago

Unsure if related but without touching my config I now all of a sudden get below error message:

2018-09-07 21:09:27 WARNING (MainThread) [homeassistant.components.cloud.iot] Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)]
2018-09-07 21:09:27 INFO (MainThread) [homeassistant.components.cloud.iot] Connection closed
tsrubar commented 6 years ago

Wow, after uninstalling of python-jose-cryptodome and warrant i get in Configuration>Home Assistant Cloud this screen: image But also few of these errors appeared: Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]

tsrubar commented 6 years ago

Actually these errors are pretty often:

Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:31 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:27 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:24 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:23 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:23 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:22 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:22 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:22 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:22 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:18 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:16 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:15 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:14 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:14 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:14 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
9:14 PM components/cloud/iot.py (WARNING)
Unable to connect: Cannot connect to host cloud.hass.io:8000 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)]
pvizeli commented 6 years ago

Time is correct?

dynasticorpheus commented 6 years ago

Time is correct on my end

tsrubar commented 6 years ago

My time is solid right at my end too image

wolph commented 6 years ago

The cloud.hass.io certificate has expired and needs to be renewed.

I suppose someone broke the Let's Encrypt script :)

Link to test: https://cloud.hass.io:8000

tsrubar commented 6 years ago

That explains a lot, I know this much more than I would like to :) So lets just wait till admin will have a look at certbot

matsube11 commented 6 years ago

Ended up here for the same certificate failure, seems to be fixed now, Cloud access is working again. Thanks

dynasticorpheus commented 6 years ago

Can confirm from my end as well.

tsrubar commented 6 years ago

I can confirm this Cloud connection status: Connected Thank you for your help!