Skip to content

Fix --bitcoin-rpc-cookie: the cookie is never base64 encoded - #216

Open
bitsagarob wants to merge 1 commit into
spacesprotocol:mainfrom
bitsagarob:fix-bitcoin-rpc-cookie-auth
Open

bitsagarob wants to merge 1 commit into
spacesprotocol:mainfrom
bitsagarob:fix-bitcoin-rpc-cookie-auth

Conversation

@bitsagarob

Copy link
Copy Markdown

--bitcoin-rpc-cookie always gets 401 Unauthorized from Bitcoin Core.

BitcoinRpcAuth::to_token returns the cookie file contents unchanged, but the result is sent as Authorization: Basic <token>, which has to be base64. The UserPass arm right above it encodes correctly, so passing --bitcoin-rpc-user and --bitcoin-rpc-password works and only the cookie path is broken. The default cookie path fallback is affected too.

auth_token_from_cookie in client/src/auth.rs already does exactly this encode and is used for spaced's own RPC server, so the fix just calls it.

The trim() is because read_to_string keeps a trailing newline if the cookie file has one, and that breaks Basic auth the same silent way.

Tested against Bitcoin Core on mainnet: 401 before, syncs after, and user/password still works.

The cookie was sent verbatim as an HTTP Basic credential, so Core rejected
every request with 401. Reuse auth_token_from_cookie, which already does
this encode for spaced's own RPC server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant