diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-10-01 16:57:25 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-10-01 16:57:25 +0200 |
commit | 1c80386bceb216ca5b5da657e03a29f9c779d58b (patch) | |
tree | 1205af8e51a25b9e2e17e8532003aba0c116a5f9 /src/rpc/protocol.cpp | |
parent | 6faffb8a83db3f209a303a4464dbdd597faad5a4 (diff) |
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.
Diffstat (limited to 'src/rpc/protocol.cpp')
-rw-r--r-- | src/rpc/protocol.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rpc/protocol.cpp b/src/rpc/protocol.cpp index f5275062a2..bb885bb5a6 100644 --- a/src/rpc/protocol.cpp +++ b/src/rpc/protocol.cpp @@ -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. |