Repository navigation
Conversation
|
Hi @araxis, Thanks for your PR. The tests you added do not follow the established directory structure for E2E tests. Also, your PR description is very difficult to follow and does not clearly state the problem which your PR addresses, how it addresses it, and which E2E tests you ran against which devices. We normally expect runs at least against an Ultimate 64, but ideally also against an Ultimate II cartridge Thanks for improving the PR further. As reference, please have a look at PR #929 or other recently merged PRs. Thanks |
|
Hi @chrisgleissner, thanks for taking the time to review this and for pointing me to #929. I've moved the tests into the established E2E/soak directory structure and revised the description to clarify the goal, implementation, and tests run on each device. I've also made the remaining hardware coverage gaps explicit. I hope the update makes the PR easier to review. Thanks again! |
|
Thanks for these amendments @araxis. It is appreciated. I see you used a 'Commodore 64 Ultimate, Slimline BASIC Beige, pinned retail v14 candidate' for testing. May I ask how you managed to acquire a slimline C64U given their shipment has not yet started as far as I know (I ordered one myself), and what v14 means? @barryw, I know you have done a lot of work to support HTTPS. Could you please review this PR? Thanks |
chrisgleissner
left a comment
There was a problem hiding this comment.
Thanks for this, @araxis. I built the branch for u64, u64ii, u2, u2plus and u2plus_L. I then ran the new suites, plus a set of target 6 checks against a local HTTP server, on master and on this branch. The devices were an Ultimate 64 Elite and an Ultimate II+L in a C64 Ultimate. Details are in the inline comments; this is the summary.
Blocking
- A clean checkout does not compile.
HTTP_RESPONSE_STRICTexists only in a patch that CI applies to the httpd submodule. - HTTPS is built only for the Ultimate 64 Elite II and the C64 Ultimate. On the Ultimate 64 and the U2+L,
https://returns 503. The TLS worker also fits in the flash of both of their ESP firmwares, so this is a scope decision rather than a hardware limit. Either way, the description should say so. - The strict parser returns 503 for plain HTTP responses with more than 20 header fields, which master handled. That includes small API responses such as those from api.github.com.
Plain HTTP fixes that already work
I measured each of these failing on master and passing on this branch, on both devices:
- Raw bodies over 895 bytes: on master, a reply block of 896 bytes never clears DATA_AV, so the client hangs.
- Raw headers of 256 bytes or more: master returns an empty status.
- #771: on master, REST stopped answering within 20 refused connects. On this branch, target 6 and REST still worked after 40.
- Handles are now released on a C64 reset.
- Close-delimited bodies: master returns them empty.
- A crash on the Ultimate 64 when the server closes before a complete header. On master, an
https://URL is sent as plain HTTP to port 443, which triggers the same crash.
None of these needs the TLS work, so a separate small PR could be merged quickly. The description should also list them; at the moment it mentions only #771.
Tests
On both devices, every device suite fails on this branch too. The HTTP parts pass and the HTTPS parts get 503; the repetition suite scored 40/40 on HTTP and 0/40 on HTTPS. Three suites stop at the telemetry preflight. The suites also leave the Command Interface setting disabled and refuse u2@c64u (see inline). On master, the lifecycle suite fails its 895-byte assertion and the smoke suite crashes the Ultimate 64, so the HTTP assertions catch what they target. The device-free https-harness passes.
TLS support and security
The certificate handling is right. It requires verification, checks the host name and sends SNI, and checks validity dates against SNTP time no more than 24 hours old. It requires TLS 1.2 or newer and never falls back to plain text.
I checked 36 public HTTPS endpoints with OpenSSL set up like the ESP: TLS 1.2 only, no ChaCha20, and the ESP-IDF 5.3 certificate bundle as the only trust store. Every endpoint that uses a host name and was up (34 of them) completed the handshake and verified. TLS itself therefore does not limit reachability today. The limits are:
- There is no TLS 1.3, so servers that require it will fail.
- The trust store is fixed in the ESP image. Servers with a private or self-signed CA cannot be reached, and changes to the root CAs need an ESP update.
- HTTPS is unavailable until SNTP has synchronised.
- Static RSA and static ECDH key exchange, and CBC suites, are offered (see inline).
Design
TLS on the ESP with TCP on the main CPU is a sound split. It works over Ethernet as well as WiFi, it uses the ESP's hardware RNG, and it keeps mbedTLS out of an application with little space left. My concerns are about scope:
- unused client code
- telemetry exposed as REST API
- an epoch persisted in
/flash - the retail C64U build recipe, and about 2,000 lines of evidence documents (
tools/c64u_https,doc/https-*,https-host.yml) that describe this PR's process rather than the firmware
The hardware results in the description come from that retail 1.1.0 backport, not from this branch. The new C and C++ code is also much denser than the rest of the tree, which makes it hard to merge by hand.
| if (socket_fd >= 0 || secure_connection) return -1; | ||
| InitReqMessage(&this->response); | ||
| this->response.usedAsResponseFromServer = 1; | ||
| this->response.usedAsResponseFromServer = HTTP_RESPONSE_STRICT; |
There was a problem hiding this comment.
HTTP_RESPONSE_STRICT is not defined in the pinned httpd submodule (ad73d32). It exists only in tools/c64u_https/httpd-response.patch, which the workflows apply before they build. A normal checkout therefore fails on every target that compiles this file: u2, u2plus, u2plus_L, u64 and u64ii. On u64:
software/network/http_request.cc:23:47: error: 'HTTP_RESPONSE_STRICT' was not declared in this scope
software/httpd is a submodule of https://github.com/GideonZ/MicroHttpServer, and ad73d32 is that repository's current master. Changes to the parser go through a PR there, as with GideonZ/MicroHttpServer#4 to #6. This repository then bumps the submodule pointer. We do not patch the submodule from a script or in CI. Could you open a PR against MicroHttpServer with the changes in httpd-response.patch? Once it is merged, this PR can bump the submodule and drop httpd-response.patch, httpd_patch.py and the workflow steps that apply it.
| body = (t_BufferedBody *)response.userContext; | ||
| if (body && body->overflow) return fail("http_body_overflow", body->size); | ||
| } | ||
| if (!body || body->overflow || response.protocol_state == eReq_HeaderTooBig || |
There was a problem hiding this comment.
Worth stating in the description: this !body check also fixes a crash. On master, when the server closes before sending a complete header, recv_response() writes body->offset = 0 through a NULL body. On the Ultimate 64 that overwrites the instruction at address 0, and the device drops off the network. JTAG shows the UCI task looping on call 0x0 at address 0. On master, an https:// URL is sent as plain HTTP to port 443, and that crashes the Ultimate 64 the same way. With this branch both cases return 503 and the device keeps running. The U2+L on master did not crash; it returned an empty reply.
| PATH_INC = $(addprefix -I, $(VPATH)) | ||
| OPTIONS = -march=$(MARCH) -mabi=$(MABI) $(EFFORT) -ffunction-sections -fdata-sections -nostartfiles -mno-div | ||
| OPTIONS += -gdwarf-2 -Os -DRISCV -DU64=2 -DUSB2513 -DOS -DIOBASE=0x10000000 -DU2P_IO_BASE=0x10100000 -DCLOCK_FREQ=100000000 -Wno-write-strings -DFP_SUPPORT=1 | ||
| OPTIONS += -DULTIMATE_HTTPS |
There was a problem hiding this comment.
This is the only target that gets HTTPS. On the Ultimate 64 and the U2+L, an https:// URL returns 503 at once (measured on both). For those devices, "no physical E2E run yet" in the description therefore means "not implemented".
Both boards have an ESP32 with the same raw bridge (raw_u64, raw_c3). As a quick check I added your TLS worker to both. Only the dispatch hook and my_uart_try_transmit_packet were needed:
- raw_u64 grew from 825,504 to 955,408 bytes.
- raw_c3 grew from 862,480 to 998,896 bytes.
Both still fit the 1 MB app partition. I did not measure runtime heap.
On those boards the ESP runs only while WiFi is enabled, because wifi.cc enables it unconditionally only for U64 == 2. That would matter for HTTPS over Ethernet. If these boards stay out of scope, please say in the description and the docs that HTTPS is for the U64 Elite II and the C64 Ultimate only.
| { | ||
| taskENTER_CRITICAL(); | ||
| detected_major=major; detected_minor=minor; | ||
| controller_ready=major==1 && minor>=16; |
There was a problem hiding this comment.
This minimum version comes from the u64ctrl numbering, which was at 1.14 before this PR. raw_u64 and raw_c3 have their own sequence, currently at 1.6, so this check cannot carry over to the other boards. An explicit capability would avoid tying the feature to one module's version number, for example a flag in the identify reply.
| + line = end + 2; | ||
| + while (*line != '\r') { | ||
| + end = strstr(line, "\r\n"); | ||
| + if (!end || hdr->FieldCount == MAX_HEADER_FIELDS) return 0; |
There was a problem hiding this comment.
This fails the whole response when it has more than MAX_HEADER_FIELDS (20) fields. The legacy parser stops storing fields at 20 and carries on. The client now uses strict mode for plain HTTP too, so this is a regression on every target.
With a local server, master returned the body for responses with 21 and with 30 fields; this branch returned 503. I measured the same on the u64 and on the U2+L. Real APIs often send more than 20 fields. When I requested them, api.github.com sent 22, raw.githubusercontent.com 23, discord.com/api 21, jsonplaceholder.typicode.com 27 and api.coinbase.com 33.
I suggest parsing every line for Content-Length and Transfer-Encoding, and simply no longer storing fields after the twentieth, instead of failing.
| rest = RestClient(args.host, password=args.password, timeout=args.timeout) | ||
| heap = json.loads(rest.expect('GET', '/v1/machine:heap')) | ||
| checked_metrics({'values': heap}) | ||
| if heap['https_bridge']['controller_minor'] != 18: |
There was a problem hiding this comment.
This requires bridge minor 18 exactly, so the suite will fail as soon as the bridge moves to 1.19. A feature check would last longer, as https_diagnostic_test.py does with last_tls_failure.
More generally, every suite fails on a device without the HTTPS provider, such as the Ultimate 64 or the U2+L. The HTTP parts pass and the HTTPS parts get 503. https-response, https-diagnostic and https-timed stop at preflight because machine:heap has no esp32 object. A capability check that skips would make the suites safe to run on every product. This suite also spends about 18 s probing httpbingo.org and httpbin.org before it checks whether the device can run it at all.
| s->code = s->port.trust(s->port.context, &s->config); | ||
| if (s->code) return s->status = HTTPS_TLS_ERROR; | ||
| mbedtls_ssl_conf_authmode(&s->config, MBEDTLS_SSL_VERIFY_REQUIRED); | ||
| mbedtls_ssl_conf_min_tls_version(&s->config, MBEDTLS_SSL_VERSION_TLS1_2); |
There was a problem hiding this comment.
The core settings here are right: verification required, host name set, TLS 1.2 minimum. Two things to consider:
- The
u64ctrlsdkconfig leavesCONFIG_MBEDTLS_SSL_PROTO_TLS1_3unset, so servers that accept only TLS 1.3 will fail. - The sdkconfig compiles in static RSA key exchange, static ECDH key exchange and CBC suites, and
MBEDTLS_SSL_PRESET_DEFAULToffers all of them. Ambedtls_ssl_conf_ciphersuites()call limited to ECDHE with AES-GCM would stop a server from choosing a suite without forward secrecy. Every server in my sample chose ECDHE with AES-GCM anyway.
| return HTTPS_OK; | ||
| } | ||
|
|
||
| https_status https_fetch(const https_request *r, https_response *out, const https_transport *t) |
There was a problem hiding this comment.
https_fetch(), https_transport and https_response are not called by the firmware. Only https_request_valid() is used, by tls_stream.c and UartTlsConnection::open(). Unless a user is planned, removing them and test_https_client.c would take a few hundred lines out of the review.
|
|
||
| /* Private monotonic state, outside exported configuration. Never truncate an | ||
| * existing slot: keeping its allocation reduces metadata changes at boot. */ | ||
| static const char *epoch_files[2]={".https-epoch-a",".https-epoch-b"}; |
There was a problem hiding this comment.
The epoch is stored in two files in the root of /flash. The first HTTPS request after every boot writes and syncs one of them, so the files are visible over FTP and the flash takes a write on every boot. The epoch only has to differ from the previous boot's, so that late ESP replies are rejected. A random 64-bit value per boot would do the same without persistent state, if the service compared epochs for inequality rather than order. This is not a blocker, but it is worth weighing against the extra code.
| resp->json->add("min_ever_free", (int)xPortGetMinimumEverFreeHeapSize()); | ||
| resp->json->add("total", (int)configTOTAL_HEAP_SIZE); | ||
| #if defined(ULTIMATE_HTTPS) | ||
| https_management_add_metrics(resp->json); |
There was a problem hiding this comment.
This adds the ESP telemetry and the bridge failure record to machine:heap and to both OpenAPI documents, including internal stage numbers and mbedTLS error codes. In addition, publish_metrics() in the ESP worker loop sends a telemetry packet every second, whether or not HTTPS is in use. That is useful during development, but as REST API it is something upstream would have to keep stable. The U2 document now also describes fields that no U2 build produces. I suggest leaving this out of the PR, or putting it behind a debug build option.
|
Thanks @araxis, and thanks @chrisgleissner for the ping. Chris's review already covers the build failure, the 20-field limit, HEAD, the version gate, the suites and the scope, and I reproduced the build failure independently (fresh worktree of fc14989, CI-matched Quartus 18.1 / RISC-V GCC 10.2.0 / ESP-IDF 5.3.1). Below are only the things his review doesn't mention. 1. The epoch can lock HTTPS out until a power cycleChris raised the
This is from reading the code, not measured. Chris's suggestion (a random per-boot epoch compared for inequality) removes all three. 2. Weak entropy when WiFi is disabledChris noted that the design uses the ESP's hardware RNG. One caveat: On the U64-II, "Disable WiFi" ( 3. Plain HTTP bodies over 16 KB now fail completelyOn master, 4. The per-second telemetry reaches images that don't expect itChris mentioned the once-a-second telemetry. One consequence: only an application built with 5. Local failures look like a server 503Master already reports connect failures as 503. With TLS, the local causes multiply: certificate rejection, DNS failure, timeout, framing error and overflow all return the same "503 SERVICE UNAVAILABLE" a real server would send ( 6. Smaller points
|
|
Hi @chrisgleissner and @barryw, Thank you both for the detailed review and testing. I really appreciate the time you’ve put into this. First, a correction: after checking the physical machine, it is a Commodore 64 Ultimate, Breadbin, BASIC Beige. My company provided it for fun, knowing I had a Commodore as a teenager, so I wasn’t involved in ordering it. “v14” is simply my internal test-build label, not an official Commodore firmware version. Your feedback gives me a clearer path forward. I plan to:
I expect to start working through these changes this weekend. In the meantime, I wanted to acknowledge the findings and explain the approach I intend to take. I’ll keep this PR in draft while working through them. Thanks again for the thorough and constructive feedback. |
|
Many thanks @barryw for the very thorough review. Much appreciated. |
|
Hi @araxis , you are very welcome in regards to the review. The ability to use HTTPS has been mentioned frequently as something that would be very beneficial - thus your PR is definitely of high interest. Also, thanks for clarifying that your comments about the C64U Slimline. Looking forward to all suggestions by @barryw and myself being on-boarded. If you use AI-enhanced engineering, I can highly recommend Opus 5.5 High, and to perform very extensive E2E red/green testing, then clearly documenting all results. I would also strongly advise to perform your own adversarial reviews and pay special attention to code consistency and low churn, i.e. focusing changes only on what is strictly needed whilst ensuring the resulting change is highly maintainable, defensible, and exceptionally well tested. I own an Ultimate 64 Elite I as well as a C64U Breadbin like you, as well as an Ultimate II+L - so happy to rerun your E2E tests once done and perform another review. Given the size of this change and the security impact of HTTPS, it could easily take some review loops to get it all 100% right and merge-ready. |
|
I'd also add that we should break big changes like this up into the smallest pieces that add incremental value. I'm notoriously bad at this, but I've been trying to get better. I know that it may be hard with things like HTTPS since a lot needs to change to make it work, but we can build on our changes as we debug and validate them. |
|
Let's not integrate this at all, until it is completely stable in a test project that doesn't have anything ultimate related. Just FreeRTOS, lwIP and the TLS additions, combined with an outgoing request and possibly an incoming server. This helps tremendously in isolating issues, do performance measurements and all. You won't need any communication with the ESP32 either, and it can be tested and benchmarked on all platforms. |
|
@GideonZ we should create a beta release channel so that we can soak changes like this to a crowd that doesnt mind pain, and when it's bug-free, we can ship it on the release channel - to people who want the pain-free experience. What do you think? |
|
@barryw Did you see my remark from 3 hours ago? |
|
@barryw The idea of a beta channel is good in principle, but how would this work in practice? We want to use a trunk-based development model with I agree that this PR needs a lot more testing, including extensive soak and stress tests. We already have an automated infrastructure for this which I used to find and fix various issues in the network surface. We could re-purpose some of the existing tooling, or at the very least reuse the concept of soak and stress tests and integrate these tests neatly and consistently with the And once the PR is thoroughly, exhaustively tested (as should be standard for any PR) and it demonstrates this via red/green tests and test evidence, it is ready to be merged to |
|
@GideonZ Yes, sorry, I should have been clearer. I actually agree with you: a standalone FreeRTOS + lwIP + TLS project is exactly the first layer I had in mind. I've been fighting with my own HTTPS attempt, and even plain encrypted sockets were hard enough to get right that isolating them first makes a lot of sense. My worry is only about what comes after. Even with good tests, something as wide as HTTPS will have edge cases that only show up on real networks with real servers, and I'd like a way for willing users to try it before everyone gets it. @chrisgleissner That's fair. A long-running beta branch would bring back exactly the drift we just got rid of, and there aren't many of us to maintain it. What about keeping trunk-based development and gating it instead? HTTPS lands on master behind an "Experimental" setting that is off by default, so master stays releasable and people who want to help test can switch it on. Tests grow as bugs turn up, so nothing regresses. I don't want to derail @araxis's PR with process talk, so I'm happy to move this to its own issue if it's worth discussing further. |
|
I am not sure how difficult this really is. I would personally opt for the mbedtls library and not try to create anything ourselves. @barryw |
|
Since @GideonZ is already taking ownership of cleaning up the network architecture with a standalone FreeRTOS + lwIP + mbedTLS foundation, this is the perfect opportunity to align that work with a broader security-by-default roadmap. Because Commodore International sells the Ultimate 64 commercially across the EU, the firmware will soon face mandatory EU Cyber Resilience Act (CRA) requirements. Transitioning legacy daemons (Telnet, FTP) to opt-in, replacing plaintext |
I never said that. |
|
@araxis, the current heads of #936 and #997 now cover the same ground from two sides: your target 6 HTTP layer and our TLS sockets on target 3, both with TLS on the ESP32. A trial merge of the two heads conflicts in seven files, mostly on the control module: the dispatcher, the radio start/stop code, the UART pool reset and the module version. Your Two smaller items: could we record the reserved thread bytes (yours Two questions: do you need TCP on the ESP32 for a reason we're missing? And would you be happy for us to bring the control-module engine into that shared plan while you keep the HTTP and parser side? Written with Claude Opus 5.5 in Claude Code. |
|
@JC-000, it's okay to bring the u64ctrl TLS engine into a shared backend while we keep target 6 and the HTTP/parser side. On your TCP question: no, we don't need TCP on the ESP32. The current provider keeps socket and TLS ownership together, but main-CPU TCP with ESP32 TLS is a viable alternative behind Commit Agreed on a shared header for the reserved thread bytes/RPCs, capability-based detection, and maintainer-assigned versions. Could you share the u64ctrl branch/commit? We can then agree the session contract and validate one target-6 HTTPS request through it before replacing the current backend. |
|
@araxis, thanks. The engine is in #1095 ( One correction to how I framed it last time: in #997 and #1095 the Ultimate already owns TCP. DNS, socket and connect run in lwIP on the main CPU, and the module only runs TLS on the ciphertext it is handed over the UART ( Your list against 1d182c9:
On the header: thread bytes On the capability bit: Proposed order:
Written with Claude Opus 5.5 in Claude Code. |
|
@araxis, step 1 works on a C64 Ultimate. Branch:
Host tests: 72 adapter checks against a fake module and a fake TCP peer, run under ASan/UBSan, plus 20 slot-sharing checks. Target 3's existing suites keep their counts. Your HTTP target and session suites pass unchanged. On a C64 Ultimate, with the image loaded into RAM and the module firmware already flashed:
Two things I'd like your view on:
Next are the session-contract items from my last comment, as commits on #1095. Your answers on the clock check, the boot nonce and the capability field decide their shape. Written with Claude Opus 5.5 in Claude Code. |
|
@JC-000, thanks for the adapter and the C64 Ultimate results. The main-CPU TCP / module TLS split works with Adapter commit Answers to your questions:
Agreed on one shared thread/RPC registry, including One host integration issue also surfaced: the all-target HTTPS build fails in Your adapter-first, contract-next order makes sense. Keep this as an integration prototype until the restart, lease, cleanup and policy cases pass; then we can switch the backend without weakening the HTTP behavior. The hardware GETs you reported are useful smoke tests, but do not yet establish those guarantees. |
|
@araxis, your three probes, the CLOSE_ALL path, the cleanup bound and the build break are fixed on
Host suites pass, also under ASan/UBSan: test_module_tls_http 119, nettls 360 and netlend 59 under both product configs, test_uart_loss 19. A withheld slot is still freed only by a module-confirmed CLOSE; the module lease below removes that limit. The session contract goes on a fork branch stacked on #1095, so #997 and #1095 stay as reviewed:
The bounds depend on one TLS step's duration, which we will measure on both devices before stating numbers.
Written with Claude Opus 5.5 in Claude Code. |
|
@JC-000, thanks for the fixes. Revision 4a9b12725 was reviewed locally. All three original failure probes now pass. The adapter's 119 checks, nettls 360 and netlend 59 in both configurations, and UART loss 19 pass under ASan/UBSan. The complete HTTPS host build also passes, along with the HTTP regressions and the original provider's RSA/ECDSA tests (21 cases, 611 checks each). These are host results, not device validation of the module adapter. Two smaller issues surfaced in the expanded checks:
Answers to your two questions:
Keeping the v2 contract on a separate branch stacked on #1095 makes sense. Slot reservation and opcode/queue allocation remain Gideon's decisions. Once the contract is implemented, the next checks are stale HELLO/replies, native-only and module-only restarts, lease expiry, clock revocation during an operation and target-3 coexistence. The proposed guarantees still need that evidence before switching backends. |
|
@araxis, both are fixed on
Host suites under ASan/UBSan: test_module_tls_http 125, the RPC suite 68, nettls 360 and netlend 59 in both product configs, test_uart_loss 19. The v2 contract takes your conditions as follows. Owner:
Clock:
Evidence: each item on your list has a host test that fails without the corresponding rule. On hardware, main-only restarts (counted only when the module boot id is unchanged), lease expiry, clock revocation during a slow GET and target-3 coexistence are planned. A module-only restart needs a bench tool that restarts the ESP32 alone, which we are adding. One thing we found in the expanded checks: with Two questions:
Written with Claude Opus 5.5 in Claude Code. |
|
Thanks,@JC-000. At
I also reproduced the IP-report delay in a host fixture using the GOT_IP handler and IDF 6.0.3 callbacks. Even an immediately accepted sample left the semaphore unsignalled, giving 15 two-second waits per report on two consecutive events. |
|
Thanks, @araxis. We take both answers. Clock: with module minus main, the main's time can be late by up to L and early by up to E. An OPEN is accepted only for d in [-5 s + L, +5 s - E]. Between that and the [-5 s - E, +5 s + L] filter it fails without a latch, and only d outside the filter latches. Precision: yes. The main switches to SNTP_SET_SYSTEM_TIME_US and OPEN2 carries milliseconds, so the 2 s of truncation goes. L is now the 500 ms transit limit for an OPEN plus 10 ms, plus the main oscillator's drift since its last NTP sample (at most about 0.7 s at 100 ppm and 2 h). E is 10 ms plus the same drift. The module's own sample adds its drift the same way. Transit: bounded per exchange. The module reports how long it held the OPEN, and the main takes RTT minus that. A session is used only when its transit is within the 500 ms limit; otherwise it is discarded and retried once. The expiry therefore stays within the validity left at OPEN. Any clock write the OPEN decides waits for that session's first STEP, which the main sends only after this check. Gap: a sample after more than 24 h is held and live sessions are revoked. It is written only after it agrees with a qualified main time from an OPEN that arrives after it returned. The 300 s, monotonic and main-generation latches stay, and a resync clears none of them. With provider sources on, SntpClock needs the same change. IP report: agreed. GOT_IP is reported first and then only starts SNTP, and HTTPS gates on time separately. Our SNTP hook posts NETIF_SNTP_TIME_SYNC itself, without blocking. Did "fresh main sample" mean an OPEN that arrives after the module's sample returns, or a new main NTP sample? Q3 and Q4 are still with Gideon. Written with Claude Opus 5.5 in Claude Code. |
|
Should target 6 accept pinned, self-signed hosts at all? Today it cannot name one: every request uses the bundle, and your usage doc says applications do not send certificates. If yes, should the pin come from a setting per host, which leaves the request format alone, or with each request? If pinning goes in, we propose that a pinned OPEN carries no time. The module's PIN mode checks only the SHA-256 of the leaf's SubjectPublicKeyInfo and already ignores the certificate's dates, chain and name, so the clock changes no verify result. The contract would still refuse a pinned OPEN whenever time is not qualified or the clocks disagree, for example during an NTP outage. A pinned OPEN would neither need a qualified clock nor set, latch or revoke anything on it. Entropy, cancel and the deadline still apply, and other sessions keep every clock rule. Written with Claude Opus 5.5 in Claude Code. |
|
@JC-000, a new For #936, let’s keep target 6 on the existing certificate bundle and leave public-key pinning for a separate proposal. |
|
@araxis Thanks, that answers both questions. The re-seed rule works for us: a new Agreed on pinning: target 6 stays on the certificate bundle for #936, and pinning can be a separate proposal if a use for it comes up. Written with Claude Opus 5.5 in Claude Code. |
|
After the first Wi-Fi disconnect, HTTPS stays unavailable until reboot. The The fix keeps the owner task and renegotiates, because the task cannot be rebuilt:
Still terminal: a Known limits, not covered. The ESP answers Initialize with Busy while the previous resource drains ( Branch
Written with Claude Sonnet 5.5 in Claude Code. |
|
Thanks, @JC-000. Your Wi-Fi reconnect test failed on I also reproduced both limits you flagged. If reconnect happens while the ESP32 is still cleaning up, Are you already working on those two cases, or would you like me to take them on #936? |
|
@araxis Thanks for verifying it. Please take both cases on #936: they turn on how the contract treats Written with Claude Opus 5.5 in Claude Code. |
The startup test drives the native owner to Active, drops and restores the Wi-Fi link, and requires the factory to become available again with a fresh lifetime. It fails today: the owner task exits after the first link loss and the one-shot start paths never create another.
A Wi-Fi disconnect cancels the provider lifetime. The owner treated the resulting runner failure as final, published Failed and let its task exit. Both start paths are one-shot, so HTTPS stayed unavailable until reboot. When the failure follows a cancelled provider lifetime, the task now retires the old negotiation, fails pending requests and waits for the next provider snapshot, then negotiates again. Every other failure is still final, and the bootstrap timeout still bounds only the first identity wait.
…open Add startup cases for a connection that is open at the drop, a data reply for a pre-drop request that arrives while the owner is disconnected, and a second drop between the provider snapshot and the offer. Each must end with the owner serving again, and none does yet. The reconnect case no longer calls provider_journal_start_owner again: only module start calls it.
Three ways a link loss still ended the owner for good: - A connection open at the drop submitted a Close that the waiting owner refused, and the failed Close retired the owner. Skip the Close once the data lifetime is cancelled, and do not retire on a Close that fails because the link was lost under it. - A data reply to a request from before the drop could arrive while the owner waited, because the data channel was open again. Drain the channel when the renegotiated session first becomes Active, before admitting requests; the UART is ordered, so every stale frame precedes the Offer reply. - A second drop between the provider snapshot and the offer made the failed offer final. Wait for the next snapshot when the lifetime just taken is already cancelled. The contract row now lists what stays terminal.
|
@JC-000 Thanks for the reconnect fix. Both cases you flagged are addressed in When initialization returns When the ESP32 restarted during renewal, the owner retired the old session at the 250 ms reply deadline. The new boot identity arrived 110 ms later, and the same owner task negotiated a fresh session. Reconnecting with the same boot identity after that timeout kept HTTPS unavailable. Both probes failed before the fix and passed afterward. All 86 host-suite steps passed. When you have hardware time, a reconnect during cleanup and a reboot during renewal would be the most useful cases to check. Traces and host results |
|
Hi @araxis and @JC-000 , many thanks for all your work on supporting TLS. It is much appreciated indeed. One question - would you mind writing up very concisely where we are on the journey towards TLS, and whether this covers outgoing calls, incoming calls, or both? There are a lot of PRs and some issues related to this, and it is a bit hard to keep track. Thank you. |
|
@chrisgleissner, our side in short. Outgoing only. Our PRs make the Ultimate a TLS client for C64 programs: through the network command target, a program opens a TLS socket ( Where. The ESP32 module runs TLS; TCP stays in lwIP on the main CPU, and the C64 sees plaintext. U64 and U64 Elite in #997, Elite II and C64 Ultimate in #1095.
All six have master merged in as of 23 November, which is what your reviews of 10 November asked for, and have no conflicts. Merged already: #1027, #1041, #1034, #1097 (the root list the engine shares). Plan: #952. #936 is also outgoing, despite the title: "target 6" is the HTTP command target, where a C64 program has the Ultimate fetch a URL, and the PR lets that URL be https://. It has its own provider on the same module; whether one engine serves both is open there. No open PR adds HTTPS to the REST API or the web UI. Next. Merge in table order, starting with #1028. From the maintainers: a review of #1028, a yes or no on #995, one engine or two, and module versions at merge. Written with Claude Opus 5.5 and Claude Fable 5.2 in Claude Code. |
|
We ran your full host suite in a Linux container at a3f6ee3 and again at the current head e32d5c6: all 86 steps passed both times, exit 0. The hardware run needs a C64 Ultimate with your module firmware flashed on the ESP32-S3, which I cannot do remotely. We will run both cases when I am back at the bench in a week or so: a reconnect while cleanup still returns One question on the reply timeout. A Renew reply later than 250 ms ( Written with Claude Opus 5.5 in Claude Code. |
Goal
Add authenticated HTTPS to the existing command-target 6 HTTP interface. Callers use the same HTTP operations and choose http:// or https:// in the URL. The transport is separated from the TLS provider so the backend can be replaced without changing that interface.
Status: draft. Controller versions 1.38 (default) and 1.39 (HTTPS provider) are provisional. The default firmware leaves the provider disabled. Confirm version allocation and merge order before installation. Hardware validation and recovery qualification remain open.
Implemented in this revision
Replaced the prototype-specific transport with a replaceable secure provider and a single-owner TLS session on the controller.
Connected native and ESP32 components with validated identity, capability negotiation, session ownership and bounded requests.
Added fail-closed handling for authentication failures, unavailable trust/time/entropy, expired deadlines, cancellation and restart invalidation.
Included the current upstream Wi-Fi reply checks and CA store, and retained plain HTTP regression coverage.
Fixed application-provider linkage in the U64-II factory target and parser preparation in reused submodule checkouts, with regressions for both failures.
Integrated the controlled HTTPS campaign with
run-tests: explicit-only selection, offline preparation, gated execution, independent peer-log audit and standard reports. Ordinary profiles cannot start it, and unaudited execution cannot report a pass.Moved boot-identity generation after successful Wi-Fi RF startup, removing application SARADC entropy manipulation. Failed starts and zero identities fail closed; reconnects retain the same boot identity.
Merged upstream Wi-Fi changes. Opening the AP scan list now preserves an active HTTPS session; disabling Wi-Fi or losing the link still cancels it. Added coverage in the upstream Wi-Fi host harnesses.
Integrated #1043: plain HTTP sends the entire request to a slow reader and times out if the peer stops making progress. An interrupted partial write resumes at the first unsent byte. HTTPS still uses its provider and its own deadlines.
Integrated #1072 and #1073. HTTP and HTTPS exchanges run on the network worker. If the C64 aborts while the worker’s reply is being prepared, that reply is discarded and the next command can run.
The independent HTTP fixes were split out and merged in #955, #956, #957 and #958. This branch retains those changes and focuses on the HTTPS integration.
Validation
After merging upstream
40188c7d, both controller images were rebuilt against the updated 112-root certificate bundle. The embedded bundle checks passed on both images. All 86 HTTP/HTTPS host-suite steps and all four reconnect and restart probes passed locally ate32d5c69.Owner recovery at
a3f6ee38builds on JC-000’s reconnect fix. A matchingBusyduring cleanup keeps HTTPS unavailable. The owner retries initialization on the same offer for up to 1.5 seconds and admits work only after a matching success. If a control reply times out, the old session is retired. A fresh handshake requires a different ESP32 boot identity and cancellation of the old provider lifetime.Both cases failed on
220e052eaand passed with this change. All 86 host-suite steps passed, including 184 RSA/ECDSA loopback cases (7,620 checks). Physical reconnect and reboot validation is still pending. Before-and-after traces and full host resultsAt
45f1119a, the read-cancellation test waits until TLS has authenticated and the client starts reading the HTTP response. With a 250 ms handshake delay, the old fixture cancelled at 164 ms without sending HTTP. The fixed fixture cancelled during the read at 292 ms; the peer received the exact request and the next request succeeded. The 750 ms limit is unchanged.All 82 host stages passed: 18,971 assertions, 37 parser tests, and 184 RSA/ECDSA cases with 184 recovery exchanges. These include 34 read-cancellation cases. Download the before/after logs, peer records and audit. SHA-256:
8ede116e9f4a7575ba931a92034302893df5e7eb2a35fe839254d35b99a79f95. Build passed; HTTPS host validation passed.Previous firmware and host validation:
13a2a1bb, including upstream700c7f2f. Download build logs, host results and peer records. SHA-256:0dfb630ba09b56833d22d07a2ffd793ab615c2976549c800f09855974940f784.make host_testspassed.Earlier results below retain their original revisions. This merge does not include the separate IDF 6 migration or new hardware results.
85a33354, including upstream303af3a9. Download the build logs, host results and peer records. SHA-256:2590628d79e7774960a943ba9bf26f2ccdb8fbd16b0a6a22ff7b1d97a6bb4b5a. HTTPS host validation passed; Build passed.6c099801, including upstreamb57d894a. Download the build logs, host results and peer records. SHA-256:af204e2765a8e482d95466752616a4f84aff6436b5db8dfa5b65017657d6222a. Build passed; HTTPS host validation passed.Remaining before ready for review
run-testsframework and validate the entry, safeguards, reporting and loopback audit locally. Physical execution is still pending.The ordinary updater retains upstream behavior. The separate experimental paired updater and RAM diagnostic remain under review and are not installation-ready artifacts. Passing host, build and emulator tests does not establish hardware readiness.
Documentation and evidence
Raw evidence archives and SHA-256 checksums
Resolved build failures and retained evidence
The first combined dispatcher failed an abort-during-publication test: it accepted an empty command before the abort was handled. The fix keeps the interrupt masked until the reply is accepted or abort cleanup resets it. The evidence includes the failing and passing runs.
The first #1043 merge passed the real socket tests, but the routing test used a fake descriptor with the real socket timeout call. The updated harness checks both timeout settings and verifies that rejecting either closes the socket without sending. The new evidence archive retains the failed and passing results.
The factory-test build failed at bf5c7b0 because the command-only target linked an application provider hook. A fresh build reproduced the failure. The corrected target excludes that hook; the regression fails without the fix, and the corrected builds and host suite pass. The factory-build archive above retains both outcomes.
A subsequent hosted build stopped before compilation during parser preparation. A forced submodule checkout had restored tracked files while retaining a patch-created test. The helper now accepts that file only when its contents match the reviewed hash, and still rejects unexpected edits. The parser-preparation archive retains the failure and passing reruns. Hosted CI subsequently passed at 7355a3e.
The startup evidence also retains a connected ECDSA
command-read-cancelpeer-check failure: its 150 ms timer fired before authentication completed. The unchanged suite subsequently passed serially; the timing race is reproduced and fixed in45f1119a(see Validation). Initial test-harness and Windows export line-ending failures are retained too. No acceptance check or production deadline was relaxed.These archives preserve earlier failures and limitations; repeated full-suite runs are not added together to inflate the test totals.