diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-16 02:21:00 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-16 02:21:00 +0200 |
commit | d87ba100ac9d012e13eddbeb460c0a658860311f (patch) | |
tree | 6d0e44dfa45bac0a6cc5d7c10ab53c453b9d2624 | |
parent | e563799518d4c9ec8e93a2dc862214ffd7a216f7 (diff) | |
download | kube-d87ba100ac9d012e13eddbeb460c0a658860311f.tar.gz kube-d87ba100ac9d012e13eddbeb460c0a658860311f.zip |
Get the correct encryption key, not the first.
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/messagepart.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/messagepart.cpp b/framework/src/domain/mime/mimetreeparser/messagepart.cpp index 4c12a9d9..611a04c5 100644 --- a/framework/src/domain/mime/mimetreeparser/messagepart.cpp +++ b/framework/src/domain/mime/mimetreeparser/messagepart.cpp | |||
@@ -927,8 +927,15 @@ bool EncryptedMessagePart::okDecryptMIME(KMime::Content &data) | |||
927 | return true; | 927 | return true; |
928 | } | 928 | } |
929 | 929 | ||
930 | if (mMetaData.isEncrypted && decryptResult.recipients.size()) { | 930 | if (mMetaData.isEncrypted) { |
931 | mMetaData.keyId = decryptResult.recipients.at(0).keyId; | 931 | mMetaData.keyId = [&] { |
932 | foreach (const auto &recipient, decryptResult.recipients) { | ||
933 | if (recipient.status.errorCode() != GPG_ERR_NO_SECKEY) { | ||
934 | return recipient.keyId; | ||
935 | } | ||
936 | } | ||
937 | return QByteArray{}; | ||
938 | }(); | ||
932 | } | 939 | } |
933 | 940 | ||
934 | if (!decryptResult.error) { | 941 | if (!decryptResult.error) { |
@@ -939,14 +946,7 @@ bool EncryptedMessagePart::okDecryptMIME(KMime::Content &data) | |||
939 | mMetaData.isEncrypted = errorCode != GPG_ERR_NO_DATA; | 946 | mMetaData.isEncrypted = errorCode != GPG_ERR_NO_DATA; |
940 | qWarning() << "Failed to decrypt : " << decryptResult.error; | 947 | qWarning() << "Failed to decrypt : " << decryptResult.error; |
941 | 948 | ||
942 | const bool noSecretKeyAvilable = [&] { | 949 | const bool noSecretKeyAvilable = mMetaData.keyId.isEmpty(); |
943 | foreach (const auto &recipient, decryptResult.recipients) { | ||
944 | if (!(recipient.status.errorCode() == GPG_ERR_NO_SECKEY)) { | ||
945 | return false; | ||
946 | } | ||
947 | } | ||
948 | return true; | ||
949 | }(); | ||
950 | bool passphraseError = errorCode == GPG_ERR_CANCELED || errorCode == GPG_ERR_NO_SECKEY; | 950 | bool passphraseError = errorCode == GPG_ERR_CANCELED || errorCode == GPG_ERR_NO_SECKEY; |
951 | //We only get a decryption failed error when we enter the wrong passphrase.... | 951 | //We only get a decryption failed error when we enter the wrong passphrase.... |
952 | if (!passphraseError && !noSecretKeyAvilable) { | 952 | if (!passphraseError && !noSecretKeyAvilable) { |