Skip to content

Say both paho majors hit ssl.match_hostname on a direct check_hostname flip - #2959

Merged
J. Nick Koston (bdraco) merged 1 commit into
mainfrom
mqtt-paho-tls-comment
Oct 21, 2026
Merged

J. Nick Koston (bdraco) merged 1 commit into
mainfrom
mqtt-paho-tls-comment

Conversation

@bdraco

Copy link
Copy Markdown
Member

What does this implement/fix?

Corrects the note beside the skip_cert_cn_check handling: a direct check_hostname flip reaches the removed ssl.match_hostname on paho 2.x exactly as on 1.x, so the comment and the architecture paragraph should not single out paho 1.x.

# before
# Never flip ``check_hostname`` directly: paho 1.x then
# calls ``ssl.match_hostname``, removed in Python 3.12.

# after
# Never flip ``check_hostname`` directly: both paho majors
# then call ``ssl.match_hostname``, removed in Python 3.12.
Evidence

paho 2.1.0's _ssl_wrap_socket still ends with ssl.match_hostname(ssl_sock.getpeercert(), self._host) whenever _tls_insecure is false and the context's check_hostname is false, which is exactly the state a direct flip produces. Verified against a local mosquitto TLS listener on Python 3.13:

paho tls_insecure_set(True) ctx.check_hostname = False directly
1.6.1 connected AttributeError: module 'ssl' has no attribute 'match_hostname'
2.1.0 connected AttributeError: module 'ssl' has no attribute 'match_hostname'

Related issue or feature (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — docs
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Frontend coordination

  • No frontend change needed
  • Companion frontend PR: esphome/device-builder-frontend#

Checklist

  • The code change is tested and works locally.
  • Pre-commit hooks pass (ruff, codespell, yaml/json/python checks).
  • Tests have been added or updated under tests/ where applicable.
  • components.index.json / definitions/components/*.json have not been hand-edited (regenerate via script/sync_components.py if a sync is needed).
  • Architecture-level changes are reflected in docs/ARCHITECTURE.md and/or docs/API.md.

@bdraco J. Nick Koston (bdraco) added the docs Documentation label Oct 21, 2026
@bdraco

Copy link
Copy Markdown
Member Author

ESPHome Bot (@esphbot) review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Both edits consistently correct documentation without changing executable code or leaving unresolved issues.

No open issues 🎉

What changed in this PR

Corrects the MQTT TLS documentation introduced in #2958 to clarify that directly disabling check_hostname reaches the removed ssl.match_hostname in both paho 1.x and 2.x.

Changes:

  • Updates the inline TLS warning and matching architecture text.
  • Leaves runtime behavior unchanged, retaining tls_insecure_set for skip_cert_cn_check.
File Description
esphome_device_builder/​controllers/​_device_mqtt_monitor.py Corrects the comment to cover both paho majors.
docs/​ARCHITECTURE.md Aligns the MQTT TLS explanation with the corrected comment.

Review effort: Balanced

@codspeed

codspeed Bot commented Oct 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing mqtt-paho-tls-comment (f7ebe34) with main (80b8d1b)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

@bdraco
J. Nick Koston (bdraco) marked this pull request as ready for review October 21, 2026 22:27
@esphbot

Copy link
Copy Markdown
Contributor

PR Review — Say both paho majors hit ssl.match_hostname on a direct check_hostname flip

This is a correct wording fix with no behaviour change, and it is ready to merge.

What the PR does well:

  • The inline comment in _apply_tls (esphome_device_builder/controllers/_device_mqtt_monitor.py:575-576) and the matching sentence in docs/ARCHITECTURE.md:544 now say the same thing. Neither singles out paho 1.x anymore.
  • No other mention of ssl.match_hostname in the repo needs updating. The only other one is the docstring of test_connect_skip_cn_check_uses_tls_insecure (tests/test_mqtt_monitor.py:2101), which already says nothing about a paho version.
  • The PR description shows evidence for both 1.6.1 and 2.1.0. I could not check the paho 2.x source myself because no paho install was available in this checkout, so I am relying on the author's table for that part.

No findings.



Automated review by Kōan (Claude) HEAD=f7ebe34 20s

@esphbot ESPHome Bot (esphbot) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.76%. Comparing base (80b8d1b) to head (f7ebe34).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2959   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files         300      300           
  Lines       26429    26429           
=======================================
  Hits        26367    26367           
  Misses         62       62           
Flag Coverage Δ
py3.12 99.73% <ø> (ø)
py3.14 99.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...device_builder/controllers/_device_mqtt_monitor.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bdraco
J. Nick Koston (bdraco) merged commit 3c52ef5 into main Oct 21, 2026
28 checks passed
@bdraco
J. Nick Koston (bdraco) deleted the mqtt-paho-tls-comment branch October 21, 2026 22:29
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants