From 50ce72218959eb2baf481aabb6cbfb4997b99640 Mon Sep 17 00:00:00 2001 From: Or Barzilay Date: Thu, 28 Nov 2019 20:18:42 +0200 Subject: [PATCH] Bugfix: CryptographySigner.__init__ fix Python 3 compatibility Fixed an issue where files were being opened in "read text" mode, instead of "read binary" mode. This cause Python 3 systems to read a str instead of bytes, which breaks the execution pretty quickly. --- adb/sign_cryptography.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adb/sign_cryptography.py b/adb/sign_cryptography.py index b042642..68ba649 100644 --- a/adb/sign_cryptography.py +++ b/adb/sign_cryptography.py @@ -25,10 +25,10 @@ class CryptographySigner(adb_protocol.AuthSigner): """AuthSigner using cryptography.io.""" def __init__(self, rsa_key_path): - with open(rsa_key_path + '.pub') as rsa_pub_file: + with open(rsa_key_path + '.pub', 'rb') as rsa_pub_file: self.public_key = rsa_pub_file.read() - with open(rsa_key_path) as rsa_prv_file: + with open(rsa_key_path, 'rb') as rsa_prv_file: self.rsa_key = serialization.load_pem_private_key( rsa_prv_file.read(), None, default_backend())