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
71.05k stars 29.71k forks source link

SmartThings could not validate the webhook URL. #113396

Closed kideg20 closed 3 weeks ago

kideg20 commented 5 months ago

The problem

SmartThings could not validate the webhook URL. Please ensure the webhook URL is reachable from the internet and try again.

I'm using Cloudflare to open my homeassistant to the internet. The URL is available from the internet. SSL/TLS is valid (generated by cloudflare)

This command:

curl -X POST https://{EXTERNAL_URL}/api/webhook/{WEBHOOK_ID} -H "Content-Type: application/json; charset=utf-8" -d $'{"lifecycle": "PING", "executionId": "00000000-0000-0000-0000-000000000000", "locale": "en", "version": "1.0.0", "pingData": { "challenge": "00000000-0000-0000-0000-000000000000"}}'

works with EXTERNAL URL output:

{"pingData": {"challenge": "00000000-0000-0000-0000-000000000000"}}

What version of Home Assistant Core has the issue?

core-2024.2.2

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

smarthings

Link to integration documentation on our website

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

Diagnostics information

Logger: homeassistant.components.smartthings.config_flow
Source: components/smartthings/config_flow.py:131
Integration: SmartThings (documentation, issues)
First occurred: 11:10:46 (2 occurrences)
Last logged: 11:11:44

API error setting up the SmartApp: {'requestId': 'XXXXXX', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://XXXXXX/api/webhook/XXXXXX', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': 'XXXXXX', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://XXXXXX/api/webhook/XXXXXX', 'message': 'Upstream target timed out', 'details': []}]}}
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 131, in async_step_pat
    app, client = await create_app(self.hass, self.api)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 145, in create_app
    app, client = await api.create_app(app)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/smartthings.py", line 110, in create_app
    entity = await self._service.create_app(app.to_data())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 171, in create_app
    return await self.post(API_APPS, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 395, in post
    return await self.request("post", self._api_base + resource, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 368, in request
    raise APIResponseError(
pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "XXXXXX", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "TargetTimeoutError", "target": "https://XXXXXX/api/webhook/XXXXXX", "message": "Upstream target timed out", "details": []}]}}

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 5 months ago

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

Code owner commands Code owners of `smartthings` 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 smartthings` 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)


smartthings documentation smartthings source (message by IssueLinks)

cybernard commented 5 months ago

Logger: homeassistant.components.smartthings.config_flow Source: components/smartthings/config_flow.py:131 integration: SmartThings (documentation, issues) First occurred: 12:10:28 PM (2 occurrences) Last logged: 12:10:54 PM

API error setting up the SmartApp: {'requestId': '1178667507691754528', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://homeassistant.xxx.com:8123/api/webhook/', 'message': 'Upstream target timed out', 'details': []}]}} API error setting up the SmartApp: {'requestId': '4235978607217639635', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://homeassistant.xxx.com:8123/api/webhook/', 'message': 'Upstream target timed out', 'details': []}]}} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 131, in async_step_pat app, client = await create_app(self.hass, self.api) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 145, in create_app app, client = await api.create_app(app) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pysmartthings/smartthings.py", line 110, in create_app entity = await self._service.create_app(app.to_data()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 171, in create_app return await self.post(API_APPS, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 395, in post return await self.request("post", self._api_base + resource, data=data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 368, in request raise APIResponseError( pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "1178667507691754528", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "TargetTimeoutError", "target": "https://homeassistant.xxx.com:8123/api/webhook/", "message": "Upstream target timed out", "details": []}]}}


No its not my firewall I have modified it to pass the required IP addresses.

alexit84 commented 5 months ago

Hello, same error here. with HA 2024.3.3

2024-03-29 12:12:01.931 DEBUG (MainThread) [homeassistant.components.smartthings.smartapp] Setup endpoint for https://home.xxxx.it:8123/api/webhook/xxxxxxx 2024-03-29 12:12:11.648 ERROR (MainThread) [homeassistant.components.smartthings.config_flow] API error setting up the SmartApp: {'requestId': '8809644606287907393', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://home.xxxx.it:8123/api/webhook/xxxxxxx', 'message': 'Upstream target timed out', 'details': []}]}} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 131, in async_step_pat app, client = await create_app(self.hass, self.api) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 145, in create_app app, client = await api.create_app(app) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pysmartthings/smartthings.py", line 110, in create_app entity = await self._service.create_app(app.to_data()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 171, in create_app return await self.post(API_APPS, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 395, in post return await self.request("post", self._api_base + resource, data=data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 368, in request raise APIResponseError( pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "8809644606287907393", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "TargetTimeoutError", "target": "https://home.xxxx.it:8123/api/webhook/xxxxxxx", "message": "Upstream target timed out", "details": []}]}}

alexit84 commented 5 months ago

I solved my problem reported above. In my cause it was caused by TLS/SSL validation issue.

  1. First I checked on https://www.digicert.com/help/. It said my TLS chain could be not totally trusted by everyone

  2. I found this https://phoenixnap.com/kb/install-ssl-certificate-nginx which pointed me out to the right direction: creating a crt bundle, merging SSL domain certificate and intermediate + CA certificate in a single fullchain.pem cert file

  3. I updated fullchain.pem file on my HA and rebooted

  4. Smarthings registration could be finally be completed!

Hope it could help someone else.

Volfieldd commented 5 months ago

hey, i had the exact same issue. My HA setup is protected by Cloudflare with full TLS Offloading. I solved the issue by "downgrading" the security from TLS 1.3 only to TLS 1.2 accepted. It solved the issue.

It seems that the TLS implementation is to be explicited quite a bit : fully trusted certification chain, and TLS 1.2 compatibility. Might be related to samsung service i guess ...

hope this will help

cybernard commented 5 months ago

I checked my website on n https://www.digicert.com/help/. I

All green check boxes.

cmargroff commented 4 months ago
  • I have Cloudflare managing SSL but I am exposing the service through Argo Tunnel
  • I have confirmed that I turned off TLS 1.3 support
  • I have checked with DigiCert and confirmed that the cert is in good standing however it complains that the cert was not issued by it. It also does not show TLS 1.3 support.
  • I confirmed that I can ping the webhook with Insomnia and got the ping data back.

Same error as reported above, request is malformed

Edit: Found the problem for anyone also using Cloudflare. CF security was blocking every request that was being made to webhook and classifying the requests as Bots. This explains why I was able to make requests to it manually.

andrepcg commented 4 months ago

CF security was blocking every request that was being made to webhook and classifying the requests as Bots. This explains why I was able to make requests to it manually.

I also confirm the issue was Cloudflare Bot fight mode turned on under Security > Bots. Disabling it fixed the issue

issue-triage-workflows[bot] commented 1 month ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.