wallet: answer the Digest challenge on the connection that issued it #137
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/wallet-rpc-digest-same-connection"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The wallet RPC Digest handshake never worked against a real
monero-wallet-rpc: the authenticated retry went out on a new TCP connection, and epee binds its Digest nonce to the connection that issued the challenge.Symptom (TUI and Android, unchanged by chain-source or creds):
Why
http_custom_handlerownshttp_server_authand is constructed per connection; its session starts with an empty nonce and counter 0, and any request without a validAuthorizationfield mints a fresh nonce (contrib/epee/src/http_auth.cpp,http_protocol_handler.h:186,223). A retry on a second socket therefore presents a nonce that socket never issued →kStale→ 401 again, forever, however correct the login is. curl and monero's own client work because they retry on the same connection.src/wallet.rs'srpc_withdid the challenge through onepost_timeout(freshTcpStream,Connection: close) and the retry through a second — andConnection: closeon the challenge made epee hang up right after the 401 anyway.Fix
post_digest/http_digest: oneTcpStreamfor the challenge and the retry, noConnection: closeon the challenge,read_one_responsehonouringContent-Length(a keep-alive response never ends in EOF; epee always sends the header, and with none the body ends at EOF, which keeps the 1 MiB cap meaningful for an open RPC), authenticated request on that same stream.--rpc-login.tests/wallet.rsgainsserve_one_conn/serve_rpc_conns(per-connection nonce) andsrc/node.rs's two wallet mocks useserve_mock_rpcon the same model. Two new tests pin the behaviour: one RPC call uses exactly one connection, and a nonce presented on another connection is refused.docs/WALLET.mdsays what a 401 means and why it is not the flow.Evidence
Real
monero-wallet-rpcv0.18.5.1 (--rpc-login owuser:owpass --offline --wallet-dir /tmp/..., wallet created and open), dialed athttp://owuser:[email protected]:18999:HEAD):WalletStatus { connected: false, last_error: Some("wallet RPC HTTP HTTP/1.1 401 Unauthorized") }— the user's exact stringWalletStatus { connected: true, last_error: None, receive_address: "44vivHYS1E25H75tpoXnLGHep9FUeHS1ZiRrFuMneo8VHQPaKRHvGjo6nd8Qvo7hHVKBCXK2bipUWQNmbxYUFtmaCADMsqD" },ping ok: trueLocal:
cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warningsclean;cargo test --locked --target x86_64-unknown-linux-gnuall targets green (wallet 42 passed).Not verified
Nothing was run on a device: the on-device Cuprate node's own "not verified" bounds in
android/CUPRATE_DAEMON.mdare unchanged. This fixes the wallet-RPC auth handshake only — an in-process Cuprate chain source that has not reached the tip still reportssyncing, notready.