[PR #5440] [MERGED] horizon-server: TLS for vanilla's management protocol, on by default #6289

Closed
opened 2026-11-03 06:17:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5440
Author: @ludovic111
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: server-admin/management-tls


📝 Commits (1)

  • 448fda9 horizon-server: TLS for vanilla's management protocol, on by default

📊 Changes

12 files changed (+1147 additions, -159 deletions)

View changed files

📝 Cargo.lock (+489 -12)
📝 crates/horizon-server/Cargo.toml (+5 -0)
📝 crates/horizon-server/src/api.rs (+3 -3)
📝 crates/horizon-server/src/http.rs (+25 -14)
📝 crates/horizon-server/src/main.rs (+1 -0)
📝 crates/horizon-server/src/management.rs (+231 -79)
➕ crates/horizon-server/src/management_tls.rs (+157 -0)
📝 crates/horizon-server/src/websocket.rs (+156 -21)
📝 docs/api/server.md (+3 -1)
📝 docs/hosting.md (+20 -4)
📝 docs/server.md (+10 -8)
📝 tools/test_management_protocol_parity.py (+47 -17)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Roadmap server-admin, part 6c: TLS for vanilla's management protocol, on by default as in vanilla. management-server-enabled = true now works on its own: the management-server-tls-enabled = false workaround from #5329 is no longer needed.

  • As vanilla's JsonRpcSslContextProvider:
    • The certificate and key come from the PKCS12 keystore at management-server-tls-keystore, relative to the server's folder.
    • Its password comes from MINECRAFT_MANAGEMENT_TLS_KEYSTORE_PASSWORD, else management-server-tls-keystore-password.
    • A missing file or a keystore that won't open stops the start, with vanilla's messages ("Failed to configure TLS for the server management protocol", "Supplied keystore is not a file or does not exist: '…'"), and logs vanilla's instructions.
  • Where Horizon differs: vanilla refuses to start with TLS on and no keystore. Horizon generates one instead:
    • a self-signed certificate for localhost, 127.0.0.1, ::1 and management-server-host;
    • saved in .horizon/management-keystore.p12, mode 0600;
    • its path and password are written to server.toml's [properties], the same way the generated secret is written;
    • every start logs the certificate's SHA-256 fingerprint, for clients to pin.
  • The stack: rustls 0.23 on ring, both already in the lockfile through ureq; p12-keystore 0.2 to read and write PKCS12; rcgen 0.14 for the generated certificate.
    • Every crate added to the lockfile (46) is MIT and/or Apache-2.0; I checked each with cargo metadata.
    • They only build into horizon-server.
  • Code changes:
    • websocket.rs reads and writes through a Link (plain TCP or TLS). It is full-duplex: the TLS session is locked only while records are decrypted or encrypted, never while waiting on the network, so notifications can later go out while the reader waits.
    • http::read_request and http::write_head work on any stream.
    • The management server has its own accept loop, so the 10 s timeout covers the TLS handshake plus the upgrade request.

Parity harness. tools/test_management_protocol_parity.py now runs both servers with TLS on, vanilla's default, using one RSA keystore made with keytool. All 33 exchanges go over TLS (the methods from #5345 included), plus the TLS version each server agrees on: TLSv1.3 on both. It passed against vanilla 26.3 on the Mac mini.

Tests: a generated keystore opens and refuses a wrong password, and vanilla's error messages are checked. An end-to-end wss:// client trusts the generated certificate and gets rpc.discover. Plain text sent to the TLS port gets no HTTP answer.

Size: +658 −147 without Cargo.lock, over the 500-line guideline. About 150 of those lines are tests, and the harness grows by 40. Cargo.lock: +489 (the new crates).

Checks (ludovics-mac-mini, at 448fda90e, on origin/main 4e4ae1050). I didn't run the full pr_ready: with Cargo.lock changed, it runs the whole workspace and 278 harnesses, so CI covers those.

Check Result
Public tree ✅
rustfmt ✅
clippy (-p horizon-server --all-targets -D warnings) ✅ (it also caught a needless borrow in api.rs, fixed here)
tests: horizon-server ✅ 81 passed
tests/test_game_home.py ✅
Parity ✅ test_management_protocol_parity.py: 33 exchanges over TLS against vanilla 26.3

Deployable: with this, the official server can turn the protocol on with management-server-enabled = true alone (localhost, generated certificate).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5440 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `server-admin/management-tls` --- ### 📝 Commits (1) - [`448fda9`](https://github.com/horizon-rust/horizon/commit/448fda90e36a8eb4c340ba1bb2b6c4bf468277fe) horizon-server: TLS for vanilla's management protocol, on by default ### 📊 Changes **12 files changed** (+1147 additions, -159 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+489 -12) 📝 `crates/horizon-server/Cargo.toml` (+5 -0) 📝 `crates/horizon-server/src/api.rs` (+3 -3) 📝 `crates/horizon-server/src/http.rs` (+25 -14) 📝 `crates/horizon-server/src/main.rs` (+1 -0) 📝 `crates/horizon-server/src/management.rs` (+231 -79) ➕ `crates/horizon-server/src/management_tls.rs` (+157 -0) 📝 `crates/horizon-server/src/websocket.rs` (+156 -21) 📝 `docs/api/server.md` (+3 -1) 📝 `docs/hosting.md` (+20 -4) 📝 `docs/server.md` (+10 -8) 📝 `tools/test_management_protocol_parity.py` (+47 -17) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Roadmap `server-admin`, part 6c: TLS for vanilla's management protocol, on by default as in vanilla. `management-server-enabled = true` now works on its own: the `management-server-tls-enabled = false` workaround from #5329 is no longer needed. - **As vanilla's `JsonRpcSslContextProvider`:** - The certificate and key come from the PKCS12 keystore at `management-server-tls-keystore`, relative to the server's folder. - Its password comes from `MINECRAFT_MANAGEMENT_TLS_KEYSTORE_PASSWORD`, else `management-server-tls-keystore-password`. - A missing file or a keystore that won't open stops the start, with vanilla's messages ("Failed to configure TLS for the server management protocol", "Supplied keystore is not a file or does not exist: '…'"), and logs vanilla's instructions. - **Where Horizon differs:** vanilla refuses to start with TLS on and no keystore. Horizon generates one instead: - a self-signed certificate for `localhost`, `127.0.0.1`, `::1` and `management-server-host`; - saved in `.horizon/management-keystore.p12`, mode 0600; - its path and password are written to server.toml's `[properties]`, the same way the generated secret is written; - every start logs the certificate's SHA-256 fingerprint, for clients to pin. - **The stack:** rustls 0.23 on ring, both already in the lockfile through ureq; `p12-keystore` 0.2 to read and write PKCS12; `rcgen` 0.14 for the generated certificate. - Every crate added to the lockfile (46) is MIT and/or Apache-2.0; I checked each with `cargo metadata`. - They only build into `horizon-server`. - **Code changes:** - `websocket.rs` reads and writes through a `Link` (plain TCP or TLS). It is full-duplex: the TLS session is locked only while records are decrypted or encrypted, never while waiting on the network, so notifications can later go out while the reader waits. - `http::read_request` and `http::write_head` work on any stream. - The management server has its own accept loop, so the 10 s timeout covers the TLS handshake plus the upgrade request. **Parity harness.** `tools/test_management_protocol_parity.py` now runs both servers with TLS on, vanilla's default, using one RSA keystore made with `keytool`. All 33 exchanges go over TLS (the methods from #5345 included), plus the TLS version each server agrees on: TLSv1.3 on both. It passed against vanilla 26.3 on the Mac mini. Tests: a generated keystore opens and refuses a wrong password, and vanilla's error messages are checked. An end-to-end `wss://` client trusts the generated certificate and gets `rpc.discover`. Plain text sent to the TLS port gets no HTTP answer. Size: +658 −147 without Cargo.lock, over the 500-line guideline. About 150 of those lines are tests, and the harness grows by 40. Cargo.lock: +489 (the new crates). **Checks** (ludovics-mac-mini, at 448fda90e, on origin/main 4e4ae1050). I didn't run the full pr_ready: with Cargo.lock changed, it runs the whole workspace and 278 harnesses, so CI covers those. | Check | Result | | --- | --- | | Public tree | ✅ | | rustfmt | ✅ | | clippy (`-p horizon-server --all-targets -D warnings`) | ✅ (it also caught a needless borrow in `api.rs`, fixed here) | | tests: horizon-server | ✅ 81 passed | | `tests/test_game_home.py` | ✅ | | Parity | ✅ `test_management_protocol_parity.py`: 33 exchanges over TLS against vanilla 26.3 | Deployable: with this, the official server can turn the protocol on with `management-server-enabled = true` alone (localhost, generated certificate). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:17:49 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6289
No description provided.