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
69.98k stars 29.06k forks source link

AndroidTC component getting ssl error setting up Nvidia Shield #121449

Open cgoudie opened 1 week ago

cgoudie commented 1 week ago

The problem

I can see others have the integration working, but I wonder if I'm the first to set it up recently. I have developer options enabled. Debugging turned on. Network debugging turned on.

2024-07-07 09:41:43.704 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post return await super().post(request, flow_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper return await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post result = await self._flow_mgr.async_configure(flow_id, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure result = await self._async_configure(flow_id, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure result = await self._async_handle_step( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step result: _FlowResultT = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/androidtv_remote/config_flow.py", line 175, in async_step_zeroconf_confirm return await self._async_start_pair() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/androidtv_remote/config_flow.py", line 100, in _async_start_pair await self.api.async_start_pairing() File "/usr/local/lib/python3.12/site-packages/androidtvremote2/androidtv_remote.py", line 336, in async_start_pairing ssl_context = self._create_ssl_context() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/androidtvremote2/androidtv_remote.py", line 180, in _create_ssl_context ssl_context.load_cert_chain(self._certfile, self._keyfile) ssl.SSLError: [SSL] PEM lib (_ssl.c:3895)

What version of Home Assistant Core has the issue?

core-2024.7.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

androidtv_remote

Link to integration documentation on our website

https://www.home-assistant.io/integrations/androidtv_remote

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 week ago

Hey there @tronikos, @drafteed, mind taking a look at this issue as it has been labeled with an integration (androidtv_remote) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `androidtv_remote` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign androidtv_remote` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


androidtv_remote documentation androidtv_remote source (message by IssueLinks)

tronikos commented 1 week ago

Can you try the following from the documentation?

If you are not able to connect to the Android TV device, or are asked to pair it again and again, try force-stopping the Android TV Remote Service and clearing its storage. On the Android TV device, go to Settings > Apps > Show system apps. Then, select Android TV Remote Service > Storage > Clear storage. You will have to pair again.

cgoudie commented 1 week ago

Trying these steps has no impact on the SSL error. Tried on another nvidia shield also, same result.

tronikos commented 1 week ago

Try deleting androidtv_remote_cert.pem and androidtv_remote_key.pem in config/.storage

cgoudie commented 1 week ago

Try deleting androidtv_remote_cert.pem and androidtv_remote_key.pem in config/.storage

This trick did it for one, but not for both. The other one now reports "already_in_progress" . I did a bunch of googling, but I'm not sure what to clear or delete to make this work.

On the SSL topic, maybe it would make sense to auto-delete this key file if it's not valid.

tronikos commented 1 week ago

Can you try adding to your configuration.yaml:

zeroconf:
  ignore:
    - androidtv_remote

Regarding the pem files, I think it makes more sense to automatically delete them once the user removes all entries to make sure the user starts fresh.

cgoudie commented 1 week ago

Can you try adding to your configuration.yaml:

zeroconf:
  ignore:
    - androidtv_remote

I tried but...

Invalid config for 'zeroconf' at configuration.yaml, line 16: 'ignore' is an invalid option for 'zeroconf', check: zeroconf->ignore

Regarding the pem files, I think it makes more sense to automatically delete them once the user removes all entries to make sure the user starts fresh.

Maybe use a lazy strategy? If the user is setting up android_tv, and there are no current devices, and the file exists, delete and recreate before setting up the first one.

tronikos commented 6 days ago

Somebody else added this zeroconf workaround in the documentation but it doesn't seem to work. I'll remove it from the documentation.

Can you enable debug logs and post logs? Can you also follow the steps in https://github.com/home-assistant/core/issues/109314 and run demo.py from the underlying library?

cgoudie commented 6 days ago

Somebody else added this zeroconf workaround in the documentation but it doesn't seem to work. I'll remove it from the documentation.

Can you enable debug logs and post logs? Can you also follow the steps in #109314 and run demo.py from the underlying library?

Actually... that zeroconf above is so bad to the config that it keeps zeroconf from loading, and I was then able to add it by hostname, then fix the config and zeroconf loads. 🤦