You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2f5ff20
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/1.guide/06.tls.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,4 +98,10 @@ While the plugin is active, [`request.tls`](/guide/handler#requesttls) provides:
98
98
>-**Deno** (2.8+) — works through the Node adapter, which runs on Deno via `node:https`. (Native `Deno.serve` cannot request client certificates.)
99
99
>-**Bun** — not currently supported: neither native `Bun.serve` nor Bun's `node:http(s)` server exposes the peer certificate to the handler, so the plugin throws. Tracked in [oven-sh/bun#16254](https://github.com/oven-sh/bun/issues/16254).
100
100
101
+
If a request nevertheless reaches the plugin over a plain (non-TLS) socket, it is answered with `496 Client certificate required` instead of running your handler with `request.tls` left `undefined`.
102
+
103
+
### Running a TLS entry through the CLI
104
+
105
+
An entry that configures `tls` (and `mtlsPlugin()`) keeps both when it is started with the [`srvx` CLI](/guide/cli): the CLI serves it over `https://` and preserves the client-certificate requirement. `--tls --cert --key` still take precedence over the entry's own settings. See [TLS precedence](/guide/cli#tls-precedence).
Copy file name to clipboardExpand all lines: docs/1.guide/10.cli.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,16 @@ The port and host are resolved with the following precedence (highest first):
105
105
3. Environment variable (`PORT` / `HOST`)
106
106
4. Default (`3000` / all interfaces)
107
107
108
+
## TLS precedence
109
+
110
+
The CLI serves over HTTPS whenever TLS is configured, resolved with the following precedence (highest first):
111
+
112
+
1. CLI flags (`--tls --cert --key`) —`--tls` requires both `--cert` and `--key`
113
+
2. Module option (`tls` exported from your server entry)
114
+
3. The `tls` passed to a `serve()` call the entry makes itself (see [Loading entries that start a server](#loading-entries-that-start-a-server))
115
+
116
+
An entry configured for TLS is therefore served over `https://` under the CLI too, and the listening URL the CLI prints reflects that. As with a direct run, TLS also enables HTTP/2 (HTTP/1.1 still allowed). Mutual TLS configured through [`mtlsPlugin()`](/guide/tls#mutual-tls-mtls) is carried over as well, so the client-certificate requirement stays enforced.
117
+
108
118
## Exit codes
109
119
110
120
In **fetch mode**, `srvx fetch` exits with code **`22`**for any non-2xx response, and `0`for a 2xx response.
server = serve({ fetch: loaded.fetch!, port: 3000 });
196
206
```
197
207
198
-
Anything the entry exports alongside its handler is on `loaded.module`, so you can read its [server options](/guide/options) and merge them with your own.
208
+
Anything the entry exports alongside its handler is on `loaded.module`, so you can read its [server options](/guide/options) and merge them with your own. Options the entry passed to its own `serve()` call are on `loaded.srvxServer.options` instead — forward the listener-level ones (`tls`, `protocol`, `node`) to your own `serve()`, as the srvx CLI does, or an entry configured for TLS ends up served in cleartext. Do **not** forward `middleware`/`plugins`: `loaded.fetch` already has them applied, so re-adding them would run them twice.
199
209
200
210
If the entry instead calls `http.createServer(handler).listen()`, the loader captures `handler` and lets the entry run to completion without binding a port. Its listen callback still fires, so setup code that runs after listen is not skipped.
0 commit comments