From b6a41513d700ef0b7cc93ddd6d1a90b5f44511a7 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Mon, 22 Jul 2019 13:43:10 +0200 Subject: [PATCH] Plugin bitcoind_: fix base64 encoding for credentials Python2.7 (as well as Python3.x) refused to execute the previously used encoding (`foo.encode('base64')`). It is unknown, whether it worked before with an older Python version. --- plugins/currency/bitcoin/bitcoind_ | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/currency/bitcoin/bitcoind_ b/plugins/currency/bitcoin/bitcoind_ index 293b72cc..efc50efe 100755 --- a/plugins/currency/bitcoin/bitcoind_ +++ b/plugins/currency/bitcoin/bitcoind_ @@ -50,6 +50,7 @@ Copyright (C) 2012 Mike Koss =cut""" +import base64 import json import os import re @@ -236,9 +237,9 @@ class Proxy(object): } request = urllib.request.Request(self.service.url, json.dumps(data)) if self.service.username: - # Strip the newline from the b64 encoding! - b64 = ('%s:%s' % (self.service.username, self.service.password)).encode('base64')[:-1] - request.add_header('Authorization', 'Basic %s' % b64) + auth_string = '%s:%s' % (self.service.username, self.service.password) + auth_b64 = base64.urlsafe_b64encode(auth_string.encode()).decode() + request.add_header('Authorization', 'Basic %s' % auth_b64) try: body = urllib.request.urlopen(request).read()