Repository navigation
Verify MTC's certificate, add timeouts and a health check (1.2.1) - #26
Merged
Merged
Conversation
MTC's certificate is verified again. Its server presents MTC's own *.mtc.nl certificate under mtc.outsystemsenterprise.com, so verification used to be switched off entirely. Now the chain is verified against the trusted CAs and the certificate must be valid for mtc.nl (MTCAdapter). If MTC installs a certificate for its real host name, the first, credential-free request of a session falls back to the normal check; when neither passes, the run stops. The password and IBAN are no longer sent over an unverified connection. - Timeouts (10 s connect, 60 s read) on every Tesla and MTC call. When MTC does not answer after a claim was sent, the claim is never sent again in the same run, because it may have arrived and claims cannot be withdrawn. - The web runner stops a run after RUNNER_RUN_TIMEOUT seconds (default 900) and shows it as failed; on POSIX it ends the whole process group, so a wrapper script in RUNNER_CMD cannot keep the run open. - Docker HEALTHCHECK on /status (web/healthcheck.py, honours RUNNER_TOKEN) and OCI image labels; the CI smoke test checks the health check. - The CSRF token and session cookie values are no longer logged. - tqdm pinned to 4.70.1. - Tests for certificate checks, the fallback, timeouts, the claim that is not resent, the run time limit and the health check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
Hardening for 1.2.1: MTC's certificate is verified again, every Tesla/MTC call has a timeout, a hanging run is stopped, and the Docker image gets a health check.
MTC certificate is verified again
MTC's server
mtc.outsystemsenterprise.compresents MTC's own certificate for*.mtc.nl(also valid formtc.nl), which fails the normal host name check. That is why verification was switched off completely (verify=False) and the warning was hidden, so the MTC password and IBAN went over an unverified connection.Now (
MTCAdapterinMTC.py):mtc.nl(urllib3assert_hostname);Checked live with the credential-free calls tesla_mtc makes before logging in (module version, JavaScript files, app store URLs): all succeed with verification on. Login and submitting were not run live (no test credentials); they use the same session and adapter.
Timeouts
HTTP_TIMEOUT = (10, 60)(connect, read) on every Tesla call and, through the adapter, on every MTC call.Web interface and Docker
RUNNER_RUN_TIMEOUT(default 900 s,0= off): a run that has not finished is stopped and shown as failed, so the page and Home Assistant never stay on Running. On POSIX the whole process group is ended, so a wrapper script inRUNNER_CMD(for example one that pipes intotee) cannot keep the run open.HEALTHCHECKwithweb/healthcheck.py(standard library, usesRUNNER_PORTandRUNNER_TOKEN): healthy/unhealthy in Docker and Synology Container Manager. The CI smoke test checks it.Logs and dependencies
tqdmpinned to 4.70.1 like the other dependencies.Tests
19 new tests:
verify=Falseanddisable_warningsnever come back.To check that the tests catch regressions, 11 deliberate bugs were introduced one at a time (for example "mtc.nl check removed", "claim resent after no answer", "hanging run not stopped"); every one made the tests fail.
Checked locally
ruff check .andpytest: 75 passed. One test (process group) is POSIX-only and runs in CI.Docs:
RUNNER_RUN_TIMEOUTand the health check indocs/web-runner.md; version 1.2.1 with a changelog entry (still Unreleased, dated at release).🤖 Generated with Claude Code