Skip to content

Commit 3f508ed

Browse files
committed
rpc: Generate auth cookie in hex instead of base64
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 #8399. Github-Pull: #8858 Rebased-From: 1c80386bceb216ca5b5da657e03a29f9c779d58b
1 parent 907c314 commit 3f508ed

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/rpc/protocol.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ boost::filesystem::path GetAuthCookieFile()
7777

7878
bool GenerateAuthCookie(std::string *cookie_out)
7979
{
80-
unsigned char rand_pwd[32];
81-
GetRandBytes(rand_pwd, 32);
82-
std::string cookie = COOKIEAUTH_USER + ":" + EncodeBase64(&rand_pwd[0],32);
80+
const size_t COOKIE_SIZE = 32;
81+
unsigned char rand_pwd[COOKIE_SIZE];
82+
GetRandBytes(rand_pwd, COOKIE_SIZE);
83+
std::string cookie = COOKIEAUTH_USER + ":" + HexStr(rand_pwd, rand_pwd+COOKIE_SIZE);
8384

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

0 commit comments

Comments
 (0)