Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for password-protected PGP keys #364

Closed
wants to merge 1 commit into from

Conversation

jmp
Copy link

@jmp jmp commented Jun 18, 2021

This PR adds support for password-protected PGP keys (when using public key encryption).

A new setting PRIVATE_PGP_KEY_PASSWORD is added that can be used with password-protected private keys.

The changes are not huge - the most important change is the PGP_PUB_DECRYPT_SQL constant which now uses the third parameter for the PGP key's password:

PGP_PUB_DECRYPT_SQL = "pgp_pub_decrypt(%s, dearmor('{}'), '{}')::%s"

The password is then fed to the SQL at get_decrypt_sql. For this I ended up changing the semantics of get_setting a little bit - it no longer raises AttributeError if the variables are not found, but rather returns None by default. This was to keep the implementation a bit simpler.

There is a small test for making sure writing and reading works with a password-protected key. I'm not sure if how I did it was the best approach, since I'm not very familiar with the test setup. So any suggestions there would be welcome.

Fixes #89.

A new setting `PRIVATE_PGP_KEY_PASSWORD` is added that
can be used with password-protected private keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for password protected public key encryption private keys
1 participant