Skip to content

Commit

Permalink
OpenGPG plugin : Fixed don't list expired/revoked GPG key (mxlgv#57)
Browse files Browse the repository at this point in the history
This commit is to implement follwoing changes:
 - closes mxlgv#91;
 - Mention that GPG key may be expired or revoked:
   in the account dialog if the number of OpenPGP keys found is 0,
   the label also notes that a key may have been revoked or expired;
 - blocks input in chat box if key is use is revoked or expired;

(cherry picked from commit 2f3ddad)
Signed-off-by: Vadim Lomovtsev <[email protected]>
  • Loading branch information
vlomovtsev authored and VadimNk committed Apr 18, 2024
1 parent 3d755db commit 5fdd7da
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/openpgp/po/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ msgstr ""

#: plugins/openpgp/src/account_settings_entry.vala:72
msgid "No keys available. Generate one!"
msgstr ""
msgstr "No keys available. Generate one or check if your keys aren't expired or revoked!"

#: plugins/openpgp/src/account_settings_entry.vala:101
msgid "Select key"
Expand Down
2 changes: 1 addition & 1 deletion plugins/openpgp/po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ msgstr "Ошибка в GnuPG"

#: plugins/openpgp/src/account_settings_entry.vala:72
msgid "No keys available. Generate one!"
msgstr "Нет доступных ключей. Стоило бы сгенерировать один!"
msgstr "Нет доступных ключей. Создайте как минимум один, либо проверьте что уже существующие (ранее созданные) ключи не были отозваны или срок их действия не закончился!"

#: plugins/openpgp/src/account_settings_entry.vala:101
msgid "Select key"
Expand Down
2 changes: 1 addition & 1 deletion plugins/openpgp/src/account_settings_entry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ public class AccountSettingsEntry : Plugins.AccountSettingsEntry {
return stack;
}
}
}
}
10 changes: 10 additions & 0 deletions plugins/openpgp/src/encryption_list_entry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
return;
}

GPG.Key key_check = GPGHelper.get_public_key(db.get_account_key(conversation.account));
if (key_check.expired || key_check.revoked) {
string status_str = key_check.expired ? " has expired." : " has been revoked.";
debug("GPG public key %s is NOT fine for encryption: it %s.\n", key_check.fpr, status_str);
input_status_callback(new Plugins.InputFieldStatus("Your GPG key " + key_check.fpr + status_str,
Plugins.InputFieldStatus.MessageType.ERROR,
Plugins.InputFieldStatus.InputState.NO_SEND));
return;
}

if (conversation.type_ == Conversation.Type.CHAT) {
string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart);
if (key_id == null) {
Expand Down
7 changes: 6 additions & 1 deletion plugins/openpgp/src/gpgme_helper.vala
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ public static Gee.List<Key> get_keylist(string? pattern = null, bool secret_only
try {
while (true) {
Key key = context.op_keylist_next();
keys.add(key);
if (!key.expired && !key.revoked) {
debug("PGP Key " + key.fpr + " is valid!");
keys.add(key);
} else {
debug("PGP Key " + key.fpr + " is either expired or revoked!");
}
}
} catch (Error e) {
if (e.code != GPGError.ErrorCode.EOF) throw e;
Expand Down

0 comments on commit 5fdd7da

Please sign in to comment.