wallet: answer the Digest challenge on the connection that issued it
monero-wallet-rpc (epee) keeps its Digest nonce per TCP connection: the `http_server_auth` lives inside `http_custom_handler`, which is created per connection, so its nonce starts empty and any request without a valid `Authorization` field mints a fresh one. The client opened a *second* connection for the authenticated retry, presenting a nonce that socket never issued — so a real wallet RPC answered 401 forever, however correct the login was. That is the `wallet RPC HTTP HTTP/1.1 401 Unauthorized` the TUI and Android showed; the canned mocks replayed the challenge on any socket, so they stayed green. - `post_digest`/`http_digest`: one `TcpStream` for the challenge and the retry, no `Connection: close` on the challenge (epee closes the socket with the 401 when the request asks for it), `read_one_response` honouring `Content-Length` (a keep-alive response never ends in EOF; with no length the body ends at EOF, which is what keeps the 1 MiB cap meaningful for an open RPC). - A 401 after our *own* challenge now reads: the login does not match the child's `--rpc-login`. - Mocks in `tests/wallet.rs` and `src/node.rs` model the per-connection nonce: `serve_one_conn`/`serve_rpc_conns`. Two tests pin it — one RPC call uses one connection, and a nonce presented on another connection is refused. - `docs/WALLET.md`: what a 401 means and why it is not the flow. Verified end-to-end against `monero-wallet-rpc` v0.18.5.1 (`--rpc-login`, `--offline`, real wallet open): unfixed tree → `wallet RPC HTTP HTTP/1.1 401 Unauthorized`; fixed tree → `connected: true` with the wallet's real address.
This commit is contained in:
parent
b805bd4ad9
commit
cb411da813
4 changed files with 435 additions and 161 deletions
|
|
@ -283,6 +283,14 @@ OnionWire refuses an RPC that answers HTTP 200 without a Digest challenge, and
|
|||
refuses URLs without credentials. Prefer `ONIONWIRE_WALLET_RPC_LOGIN` over
|
||||
userinfo in the URL. Do not log the password.
|
||||
|
||||
`monero-wallet-rpc` mints its Digest nonce **per TCP connection** (epee's
|
||||
`http_custom_handler` owns the auth state), so the challenge and the
|
||||
authenticated retry have to ride the same socket — a retry on a fresh connection
|
||||
is refused with 401 no matter how correct the login is. OnionWire does exactly
|
||||
that. A `wallet RPC HTTP HTTP/1.1 401 Unauthorized` status therefore means one
|
||||
thing: the login does not match the child's `--rpc-login`. Regenerate the child
|
||||
(and its sealed creds) rather than retrying.
|
||||
|
||||
## The spend-authority warning
|
||||
|
||||
An OnionWire instance pointed at a **spend-capable** `monero-wallet-rpc` is a
|
||||
|
|
|
|||
Loading…
Reference in a new issue