From: Kefu Chai Date: Tue, 7 Apr 2020 05:29:27 +0000 (+0800) Subject: test/rgw/rgw_multi: pass bytes to hmac.new() X-Git-Tag: v14.2.10~17^2~51 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd81792fb120dd89bdeb3db4b4eda8a73ad69c3e;p=ceph.git test/rgw/rgw_multi: pass bytes to hmac.new() in Python3, `key` passed to `hmac.new()` should be bytes or bytearray Signed-off-by: Kefu Chai (cherry picked from commit adfcf08588e6031be837602dc4d1f8d6d14d795b) --- diff --git a/src/test/rgw/rgw_multi/zone_ps.py b/src/test/rgw/rgw_multi/zone_ps.py index 000bc41a3890..7bfcdb736eed 100644 --- a/src/test/rgw/rgw_multi/zone_ps.py +++ b/src/test/rgw/rgw_multi/zone_ps.py @@ -86,7 +86,7 @@ def make_request(conn, method, resource, parameters=None, sign_parameters=False, string_to_sign = method + '\n\n\n' + string_date + '\n' + resource if sign_parameters: string_to_sign += url_params - signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, + signature = base64.b64encode(hmac.new(conn.aws_secret_access_key.encode('utf-8'), string_to_sign.encode('utf-8'), hashlib.sha1).digest()).decode('ascii') headers = {'Authorization': 'AWS '+conn.aws_access_key_id+':'+signature, @@ -223,7 +223,7 @@ class PSTopicS3: method = 'POST' string_to_sign = method + '\n\n' + content_type + '\n' + string_date + '\n' + resource log.debug('StringTosign: %s', string_to_sign) - signature = base64.b64encode(hmac.new(self.conn.aws_secret_access_key, + signature = base64.b64encode(hmac.new(self.conn.aws_secret_access_key.encode('utf-8'), string_to_sign.encode('utf-8'), hashlib.sha1).digest()).decode('ascii') headers = {'Authorization': 'AWS '+self.conn.aws_access_key_id+':'+signature, @@ -265,7 +265,7 @@ class PSTopicS3: method = 'POST' string_to_sign = method + '\n\n' + content_type + '\n' + string_date + '\n' + resource log.debug('StringTosign: %s', string_to_sign) - signature = base64.b64encode(hmac.new(self.conn.aws_secret_access_key, + signature = base64.b64encode(hmac.new(self.conn.aws_secret_access_key.encode('utf-8'), string_to_sign.encode('utf-8'), hashlib.sha1).digest()).decode('ascii') headers = {'Authorization': 'AWS '+self.conn.aws_access_key_id+':'+signature,