Add support for password-protected PGP keys #364
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:The password is then fed to the SQL at
get_decrypt_sql
. For this I ended up changing the semantics ofget_setting
a little bit - it no longer raisesAttributeError
if the variables are not found, but rather returnsNone
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.