Bug 246590 - Create s/MIME mail: key selection dialog search for lastname not mail address.
Summary: Create s/MIME mail: key selection dialog search for lastname not mail address.
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: crypto (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Andre Heinecke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-03 10:49 UTC by Ludwig Reiter
Modified: 2011-02-24 14:01 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludwig Reiter 2010-08-03 10:49:42 UTC
Version:           unspecified (using Devel) 
OS:                Linux

Version: 4.5~e5.20100730.1158333-kk2.1158321 (enterprise5)

Reproducible: Always

Steps to Reproduce:
0. Have two S/MIME keys with same lastname and different address.
1. Send a S/MIME mail.


Actual Results:  
The keys selection dialog appears.

Expected Results:  
Should find the right address.
Comment 1 Tobias Koenig 2010-12-29 12:00:13 UTC
commit fd1ce7087f79f0c41e8c87d4f202577b097a733e
branch master
Author: Tobias Koenig <tokoe@kde.org>
Date:   Wed Dec 29 11:57:44 2010 +0100

    Always look up keys by canonical email address
    
    The original code did first try to look up the key by
    non-canonical email address (e.g. 'Joe User <joe@example.org>') which
    can lead to wrong key results if there are keys with the same name but
    different email addresses. The fallback lookup with canonical address
    wouldn't be triggered in this case, because the first lookup did return
    a result (although a wrong one).
    Now we only do one lookup with the canonical email address.
    
    BUG: 246590
    CCMAIL: marc@kdab.com

diff --git a/messagecomposer/keyresolver.cpp b/messagecomposer/keyresolver.cpp
index 6667acd..c02e131 100644
--- a/messagecomposer/keyresolver.cpp
+++ b/messagecomposer/keyresolver.cpp
@@ -1666,17 +1666,9 @@ std::vector<GpgME::Key> Kleo::KeyResolver::getEncryptionKeys( const QString & pe
   }
 
   // Now search all public keys for matching keys
-  std::vector<GpgME::Key> matchingKeys = lookup( QStringList( person ) );
+  std::vector<GpgME::Key> matchingKeys = lookup( QStringList( address ) );
   matchingKeys.erase( std::remove_if( matchingKeys.begin(), matchingKeys.end(),
                       NotValidEncryptionKey ), matchingKeys.end() );
-  // if no keys match the complete address look for keys which match
-  // the canonical mail address
-  if ( matchingKeys.empty() ) {
-    matchingKeys = lookup( QStringList( address ) );
-    matchingKeys.erase( std::remove_if( matchingKeys.begin(), matchingKeys.end(),
-                                        NotValidEncryptionKey ),
-                                        matchingKeys.end() );
-  }
 
   // if called with quite == true (from EncryptionPreferenceCounter), we only want to
   // check if there are keys for this recipients, not (yet) their validity, so
Comment 2 Ludwig Reiter 2011-02-24 14:01:30 UTC
Andre, I have no idea how to test this, your issue.