OpenGPG plugin : Fixed don't list expired/revoked GPG key (#57)

This commit is to implement follwoing changes:
 - closes #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 2f3ddad1e87f99cdda9d42dbabc528c2b29c0476)
Signed-off-by: Vadim Lomovtsev <jelezny@gmail.com>
This commit is contained in:
Vadim Lomovtsev 2024-04-17 15:33:35 +03:00 committed by GitHub
parent 0ca02a72f4
commit 8f4d78910c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 4 deletions

View file

@ -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"

View file

@ -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"

View file

@ -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) {

View file

@ -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;