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

OpenGPG plugin: Don't list expired/revoked GPG key #57

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading