Skip to content
Permalink
Browse files Browse the repository at this point in the history
First working (but rough) version to omit revoked and disabled keys from
Add account-Security and Privacy-Encryption pulldown.
  • Loading branch information
JackDca committed Sep 21, 2018
1 parent 6199efa commit 49b64f6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions mailpile/crypto/gpgi.py
Expand Up @@ -810,6 +810,9 @@ def list_secret_keys(self, selectors=None):
# state when listing secret keys; it seems internally only the
# public key is disabled. This makes it hard for us to reason about
# which keys can actually be used, so we compensate...
# *** FIXME JackDca 2018-09-21 - Above behaviour not seen in 2.1.18 if
# --with-colons is used (but true for human-readable output) so this
# code could be deleted.
list_keys = ["--fingerprint"]
for fprint in set(secret_keys):
list_keys += ["--list-keys", fprint]
Expand Down
17 changes: 15 additions & 2 deletions mailpile/plugins/crypto_gnupg.py
Expand Up @@ -387,11 +387,24 @@ class GPGKeyListSecret(Command):
"""List Secret GPG Keys"""
ORDER = ('', 0)
SYNOPSIS = (None, 'crypto/gpg/keylist/secret',
'crypto/gpg/keylist/secret', '<address>')
'crypto/gpg/keylist/secret', '[<check>]')
HTTP_CALLABLE = ('GET', )
HTTP_QUERY_VARS = {'check': 'True to omit disabled, expired, revoked keys'}

def command(self):
res = self._gnupg().list_secret_keys()
args = list(self.args)
if len(args) > 0:
check = args[0]
else:
check = self.data.get('check', '')
check = 'True' in check

all = self._gnupg().list_secret_keys()
if check:
res = {fprint : all[fprint] for fprint in all
if not (all[fprint]['revoked'] or all[fprint]['disabled'])}
else:
res = all
return self._success("Searched for secret keys", res)


Expand Down
2 changes: 1 addition & 1 deletion shared-data/default-theme/html/profiles/account-form.html
Expand Up @@ -714,7 +714,7 @@
name="security-pgp-key">
<option value="!CREATE:RSA2048">{{_("Create a new 2048 bit RSA key")}}</option>
<option value="!CREATE:RSA3072" class="fpa-pgp-key-default">{{_("Create a new 3072 bit RSA key")}}</option>
{%- set pgp_keys = mailpile('crypto/gpg/keylist/secret').result %}
{%- set pgp_keys = mailpile('crypto/gpg/keylist/secret','True').result %}
{%- for fingerprint in pgp_keys -%}
{%- set key = pgp_keys[fingerprint] -%}
{%- for uid in key.uids %}
Expand Down

0 comments on commit 49b64f6

Please sign in to comment.