]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rgw/rgw_multi: pass bytes to hmac.new()
authorKefu Chai <kchai@redhat.com>
Tue, 7 Apr 2020 05:29:27 +0000 (13:29 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 14 Jun 2020 08:34:52 +0000 (16:34 +0800)
in Python3, `key` passed to `hmac.new()` should be bytes or bytearray

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit adfcf08588e6031be837602dc4d1f8d6d14d795b)

src/test/rgw/rgw_multi/zone_ps.py

index e22200e2665eadf9be3b227daa5dd6d89cbec9ad..9e3bdd9587b0bb8e8da9cd03948d40a3b3f88634 100644 (file)
@@ -82,7 +82,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())
     headers = {'Authorization': 'AWS '+conn.aws_access_key_id+':'+signature,
@@ -219,7 +219,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())
         headers = {'Authorization': 'AWS '+self.conn.aws_access_key_id+':'+signature,
@@ -261,7 +261,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())
         headers = {'Authorization': 'AWS '+self.conn.aws_access_key_id+':'+signature,