Skip to content

Commit

Permalink
rpc: Generate auth cookie in hex instead of base64
Browse files Browse the repository at this point in the history
Base64 contains '/', and the '/' character in credentials is problematic
for AuthServiceProxy which represents the RPC endpoint as an URI with
user and password embedded.

Closes bitcoin#8399.
  • Loading branch information
laanwj committed Oct 1, 2016
1 parent 6faffb8 commit 1c80386
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rpc/protocol.cpp
Expand Up @@ -77,9 +77,10 @@ boost::filesystem::path GetAuthCookieFile()

bool GenerateAuthCookie(std::string *cookie_out)
{
unsigned char rand_pwd[32];
GetRandBytes(rand_pwd, 32);
std::string cookie = COOKIEAUTH_USER + ":" + EncodeBase64(&rand_pwd[0],32);
const size_t COOKIE_SIZE = 32;
unsigned char rand_pwd[COOKIE_SIZE];
GetRandBytes(rand_pwd, COOKIE_SIZE);
std::string cookie = COOKIEAUTH_USER + ":" + HexStr(rand_pwd, rand_pwd+COOKIE_SIZE);

/** the umask determines what permissions are used to create this file -
* these are set to 077 in init.cpp unless overridden with -sysperms.
Expand Down

0 comments on commit 1c80386

Please sign in to comment.