2

Since 0.12 RPC uses a "random cookie":https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.12.0.md#rpc-random-cookie-rpc-authentication for authentication, but it's not clear how to use this cookie when accessing RPC.

I'm trying things like the below, without success (401 Unauthorized)

$Request = array(
    'http' => array(
        'method' => 'POST',
        'header' => "Content-type: application/json\r\n".
                    'Cookie: __cookie__=contentsOf.cookie',
        'content' => $Params
        )
    );
if (!$Response = file_get_contents(BITCOIN_RPC_URL, false, stream_context_create($Request))) {
    return false;
}

Every example I find online uses the user:pass authentication, I've yet to see an example using cookies.

1 Answer 1

6

Not sure if you're still looking for an answer, but I just stumbled upon this myself and for the benefit of anyone running into this.

Even though it's called cookie based authentication, you still authenticate via Basic HTTP.

Let's say your cookie was __cookie__:somerandomlongstring then:

  • Username __cookie__
  • Password somerandomlongstring

I figured this out after finding this comment on Github

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.