Verify TLS on the AWS IoT HTTP calls - #173
Open
OdynBrouwer wants to merge 1 commit into
Open
OdynBrouwer wants to merge 1 commit into
OdynBrouwer wants to merge 1 commit into
Conversation
Every request the AWS IoT backend made passed ssl=False to aiohttp: visitor authentication (which returns the bearer token), QR binding, device discovery, state polling, and the v2 control command. That switches certificate validation off, so tokens and spa control traffic could be read or rewritten by anyone able to intercept TLS - hostile Wi-Fi, a compromised router. The other two backends verify normally, and this backend's own WebSocket client already uses Home Assistant's SSL context. aiohttp does not disable verification by default either, so the only thing ssl=False achieved here was removing a protection: this was a leftover from developing against the endpoint, not a decision. All five call sites now use the session's default, verified TLS behaviour. No test pinned ssl=False, and the new tests hold the line: two drive `_do_get()` and `_do_post()` and assert no ssl argument reaches the session, and a third scans the module for `ssl=False`, which also covers the credential-bearing and encrypted call sites (authenticate, bind_qr_code, the v2 command) that a unit test would need half a request pipeline to drive. Verified live against all three regional endpoints - EU, US and CN - with Home Assistant's SSL context and with a stock ssl.create_default_context(): each presents a certificate whose common name matches the host, issued by Amazon, valid until March 2027. A plain GET returns 404 rather than a TLS error, which is the point: the handshake and the verification succeed, so removing ssl=False cannot break existing installs. That manual check is the one the issue asked for, since the suite cannot answer it.
OdynBrouwer
marked this pull request as draft
September 16, 2026 16:45
OdynBrouwer
marked this pull request as ready for review
September 16, 2026 16:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #156
Every request the AWS IoT backend made passed ssl=False to aiohttp: visitor authentication (which returns the bearer token), QR binding, device discovery, state polling, and the v2 control command. That switches certificate validation off, so tokens and spa control traffic could be read or rewritten by anyone able to intercept TLS - hostile Wi-Fi, a compromised router.
The other two backends verify normally, and this backend's own WebSocket client already uses Home Assistant's SSL context. aiohttp does not disable verification by default either, so the only thing ssl=False achieved here was removing a protection: this was a leftover from developing against the endpoint, not a decision.
All five call sites now use the session's default, verified TLS behaviour. No test pinned ssl=False, and the new tests hold the line: two drive
_do_get()and_do_post()and assert no ssl argument reaches the session, and a third scans the module forssl=False, which also covers the credential-bearing and encrypted call sites (authenticate, bind_qr_code, the v2 command) that a unit test would need half a request pipeline to drive.Verified live against all three regional endpoints - EU, US and CN - with Home Assistant's SSL context and with a stock ssl.create_default_context(): each presents a certificate whose common name matches the host, issued by Amazon, valid until March 2027. A plain GET returns 404 rather than a TLS error, which is the point: the handshake and the verification succeed, so removing ssl=False cannot break existing installs. That manual check is the one the issue asked for, since the suite cannot answer it.
Verified
Removing
ssl=Falseis only safe if the gateway presents a certificate default validation accepts, and the test suite cannot answer that - so I checked it live against all three regional endpoints, with Home Assistant's SSL context and with a stockssl.create_default_context():smarthub-eu.bestwaycorp.com/)smarthub-us.bestwaycorp.comsmarthub.bestwaycorp.cnA plain GET to
/is enough: getting any HTTP status back means the handshake and the verification succeeded, where an untrusted or mismatched certificate would have failed first.Also ran locally before opening: the full suite (292 tests) and the complete
pre-commitgate.I could not exercise the authenticated calls themselves - I have no valid visitor credentials - but TLS validation is a property of the endpoint rather than of the request, and all five call sites talk to those same three hosts.