Commit ddf99af9 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Exclude key to certify from possible certification keys

A key cannot be certified with itself. Selecting the key to certify as
certification key is treated as invalid selection. So do not offer
the key to certify as certification key in the first place.

GnuPG-bug-id: 5245
parent 1becdd7d
Pipeline #61543 passed with stage
in 13 minutes and 58 seconds
......@@ -136,6 +136,25 @@ public:
bool matches(const GpgME::Key &key, Kleo::KeyFilter::MatchContexts contexts) const override
if (!(availableMatchContexts() & contexts)) {
return false;
if (_detail::ByFingerprint<std::equal_to>()(key, mExcludedKey)) {
return false;
return DefaultKeyFilter::matches(key, contexts);
void setExcludedKey(const GpgME::Key &key)
mExcludedKey = key;
GpgME::Key mExcludedKey;
class UserIDModel : public QStandardItemModel
......@@ -248,7 +267,7 @@ public:
auto secKeyLay = new QHBoxLayout{q};
secKeyLay->addWidget(new QLabel(i18n("Certify with:")));
mSecKeySelect->setKeyFilter(std::shared_ptr<KeyFilter>(new SecKeyFilter()));
secKeyLay->addWidget(mSecKeySelect, 1);
......@@ -423,6 +442,10 @@ public:
mTarget = key;
auto keyFilter = std::make_shared<SecKeyFilter>();
......@@ -489,7 +512,8 @@ public:
if (selectedUserIDs().empty()) {
return false;
// do not accept if the keys are the same
// do not accept if the key to certify is selected as certification key;
// this shouldn't happen because the key to certify is excluded from the choice, but better safe than sorry
if (_detail::ByFingerprint<std::equal_to>()(mTarget, mSecKeySelect->currentKey())) {
return false;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment