diff options
Diffstat (limited to '')
| -rw-r--r-- | docs/SERVER_SETUP.md | 100 | ||||
| -rw-r--r-- | docs/TESTING.md | 8 |
2 files changed, 105 insertions, 3 deletions
diff --git a/docs/SERVER_SETUP.md b/docs/SERVER_SETUP.md new file mode 100644 index 0000000..e2f3177 --- /dev/null +++ b/docs/SERVER_SETUP.md | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | # Server setup | ||
| 2 | |||
| 3 | The server speaks TLS and needs a PKCS#12 identity (`identity.p12`) plus the | ||
| 4 | PEM key/certificate used to build it. The files are read from the current | ||
| 5 | working directory. | ||
| 6 | |||
| 7 | ## Quick start | ||
| 8 | |||
| 9 | From the project root: | ||
| 10 | |||
| 11 | ```sh | ||
| 12 | cargo run --bin server -- --init | ||
| 13 | cargo run --bin server | ||
| 14 | ``` | ||
| 15 | |||
| 16 | `--init` creates a self-signed development identity and exits. The next | ||
| 17 | command starts the server on `127.0.0.1:11525`. | ||
| 18 | |||
| 19 | If `identity.p12` is missing at startup, the server now prints these same | ||
| 20 | instructions instead of only the raw OS error. | ||
| 21 | |||
| 22 | ## What `--init` creates | ||
| 23 | |||
| 24 | | File | Purpose | | ||
| 25 | | --- | --- | | ||
| 26 | | `identity.p12` | PKCS#12 identity loaded by `native-tls`. Empty password. Uses PBE-SHA1-3DES and a SHA-1 MAC so the Windows SChannel backend can load it. | | ||
| 27 | | `key.pem` | RSA private key used to build the identity. Not read at runtime. | | ||
| 28 | | `cert.pem` | Public certificate, useful for inspection. | | ||
| 29 | |||
| 30 | On Unix, `identity.p12` and `key.pem` are set to mode `0600`. All three are | ||
| 31 | ignored by git (`*.p12`, `*.pem`, `*.key`). | ||
| 32 | |||
| 33 | ## Manual setup | ||
| 34 | |||
| 35 | If `openssl` is not installed or you want to control the certificate: | ||
| 36 | |||
| 37 | ```sh | ||
| 38 | openssl req -x509 -newkey rsa:2048 \ | ||
| 39 | -keyout key.pem -out cert.pem \ | ||
| 40 | -days 3650 -nodes -subj "/CN=localhost" | ||
| 41 | |||
| 42 | openssl pkcs12 -export -out identity.p12 \ | ||
| 43 | -inkey key.pem -in cert.pem -passout pass: | ||
| 44 | ``` | ||
| 45 | |||
| 46 | The password must be empty because the server calls | ||
| 47 | `Identity::from_pkcs12(&data, "")`. | ||
| 48 | |||
| 49 | ## Running | ||
| 50 | |||
| 51 | ```sh | ||
| 52 | # default: 127.0.0.1:11525 | ||
| 53 | cargo run --bin server | ||
| 54 | |||
| 55 | # listen on all interfaces | ||
| 56 | cargo run --bin server -- -i 0.0.0.0 -p 11525 | ||
| 57 | |||
| 58 | # show options | ||
| 59 | cargo run --bin server -- --help | ||
| 60 | ``` | ||
| 61 | |||
| 62 | Then start the client in another terminal: | ||
| 63 | |||
| 64 | ```sh | ||
| 65 | cargo run --bin client | ||
| 66 | ``` | ||
| 67 | |||
| 68 | On first contact the client prints the SPKI fingerprint and pins it. If you | ||
| 69 | regenerate the server identity, the client will reject the new key; run | ||
| 70 | `forget-host` in the client if the change is intentional. | ||
| 71 | |||
| 72 | ## Windows | ||
| 73 | |||
| 74 | `--init` shells out to `openssl`, so OpenSSL must be installed and on `PATH` | ||
| 75 | (Git for Windows, WSL, or a standalone OpenSSL build). The generated files work | ||
| 76 | the same way. `--init` uses SChannel-friendly PKCS#12 algorithms; if you build | ||
| 77 | the identity by hand on Windows, use: | ||
| 78 | |||
| 79 | ```sh | ||
| 80 | openssl pkcs12 -export -out identity.p12 -inkey key.pem -in cert.pem \ | ||
| 81 | -passout pass: -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -macalg sha1 | ||
| 82 | ``` | ||
| 83 | |||
| 84 | ## Security notes | ||
| 85 | |||
| 86 | - This is a self-signed development identity with an empty PKCS#12 password. | ||
| 87 | Treat `key.pem` and `identity.p12` as secrets and do not commit them. | ||
| 88 | - The trust model is TOFU: clients pin the SPKI fingerprint on first contact. | ||
| 89 | A changed key is a loud error, not an automatic re-trust. | ||
| 90 | - For a public deployment, use a CA-issued certificate and protect the | ||
| 91 | PKCS#12 with a password; the current server code expects an empty password. | ||
| 92 | |||
| 93 | ## Troubleshooting | ||
| 94 | |||
| 95 | | Symptom | Fix | | ||
| 96 | | --- | --- | | ||
| 97 | | `Failed to initialize TLS: Could not read TLS identity` | Run `cargo run --bin server -- --init`. | | ||
| 98 | | `Address already in use` | Stop the other server or pass `-p <port>`. | | ||
| 99 | | Client says `HOST KEY CHANGED` | The server certificate changed. If intentional, run `forget-host` in the client. | | ||
| 100 | | `openssl` not found | Install OpenSSL or use the manual commands on a machine that has it. | | ||
diff --git a/docs/TESTING.md b/docs/TESTING.md index 6cac6fa..55f5422 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md | |||
| @@ -15,19 +15,21 @@ shared global database. Each test owns its state. | |||
| 15 | | `tests/client_ui.rs` | Help, history, completion, bet parsing, display width, cursor math. | | 15 | | `tests/client_ui.rs` | Help, history, completion, bet parsing, display width, cursor math. | |
| 16 | | `tests/protocol.rs` | Newline buffering and timeout/error classification. | | 16 | | `tests/protocol.rs` | Newline buffering and timeout/error classification. | |
| 17 | | `tests/server_core.rs` | Handler, bcrypt migration, SQL injection, transaction rollback, `plays` audit, sessions. | | 17 | | `tests/server_core.rs` | Handler, bcrypt migration, SQL injection, transaction rollback, `plays` audit, sessions. | |
| 18 | | `tests/server_setup.rs` | `--init` identity generation, PKCS#12 loadability, overwrite refusal. | | ||
| 18 | | `tests/slots.rs` | Server slots payout rules and overflow handling. | | 19 | | `tests/slots.rs` | Server slots payout rules and overflow handling. | |
| 19 | | `tests/storage.rs` | Client/server SQLite storage helpers. | | 20 | | `tests/storage.rs` | Client/server SQLite storage helpers. | |
| 20 | | `tests/tofu.rs` | SPKI fingerprint and TOFU decisions. | | 21 | | `tests/tofu.rs` | SPKI fingerprint and TOFU decisions. | |
| 21 | 22 | ||
| 22 | `tests/tofu.rs` shells out to `openssl`, so run it on a machine where the | 23 | `tests/tofu.rs` and `tests/server_setup.rs` shell out to `openssl`, so run them |
| 23 | `openssl` CLI is available. | 24 | on a machine where the `openssl` CLI is available. |
| 24 | 25 | ||
| 25 | ## Manual TUI checklist | 26 | ## Manual TUI checklist |
| 26 | 27 | ||
| 27 | There is no CI. Run this on Linux and on a Windows VM before a release. | 28 | There is no CI. Run this on Linux and on a Windows VM before a release. |
| 28 | Use an 80-column terminal because several output lines are width-sensitive. | 29 | Use an 80-column terminal because several output lines are width-sensitive. |
| 29 | 30 | ||
| 30 | 1. Start the server with a valid `identity.p12`, then start the client. | 31 | 1. Run `cargo run --bin server -- --init` once, then start the server with a |
| 32 | valid `identity.p12` and start the client. | ||
| 31 | 2. First contact prints three lines and the 64-character fingerprint does not | 33 | 2. First contact prints three lines and the 64-character fingerprint does not |
| 32 | wrap at 80 columns. `Connected to ...` shows a one-decimal ping. | 34 | wrap at 80 columns. `Connected to ...` shows a one-decimal ping. |
| 33 | 3. `register` / `login`: backspace removes one `*` per key, Esc cancels the | 35 | 3. `register` / `login`: backspace removes one `*` per key, Esc cancels the |
