Fix load pem private key with the PEM encoded data by g1im2 · Pull Request #162 · google/python-adb · GitHub
Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Fix load pem private key with the PEM encoded data#162

Open
g1im2 wants to merge 1 commit into
google:masterfrom
g1im2:master
Open

Fix load pem private key with the PEM encoded data#162
g1im2 wants to merge 1 commit into
google:masterfrom
g1im2:master

Conversation

@g1im2

@g1im2 g1im2 commented Jun 17, 2019

Copy link
Copy Markdown

fix problem like this issues "pyca/cryptography#2730", and it also happened in here.

@coveralls

Copy link
Copy Markdown

@greateggsgreg greateggsgreg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely needs to be fixed. An alternative method is to open the files in binary (mode "rb") so we don't need to convert to bytes after the fact. Example:

with open(rsa_key_path + '.pub', 'rb') as rsa_pub_file:
       self.public_key = rsa_pub_file.read()

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())

@JeffLIrion

Copy link
Copy Markdown
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants