Multiple smartcard (reader) / app support in Kleopatra
Testing, NormalPublic

Description

Kleopatra currently only supports one smartcard.
This is basically just the smartcard that you get with "gpg --card-edit"

GnuPG supports multiple smartcards / readers at once and I think that this is also a use case that Kleopatra should support.

So the smartcard management should have support for different smartcards with different apps.

Caution for testing: I recently noticed that GnuPG stable did not support more then four smartcard readers at once. For that 0e721b635d6105e1a5b443684116fb9edfe77f92 is needed.

Details

Commits
rKLEOPATRA4ded5af09c3f: Make smartcard management work with GnuPG 2.2.x
rM74c8131d809b: cpp: Add support for gpgme_cancel
rMff23e24063fe: Add Assuan transaction that forwards status lines to another object
rKLEOPATRAe084c2a2642e: Use a more modern approach to watch for smartcard removal
rKLEOPATRA218096f8a1f9: Add the card holder to the card labels shown for the tabs
rKLEOPATRA81569bb8405f: Ask user for target card if multiple cards are suitable for key to card
rKLEOPATRA57cf71b043d1: Show nicer serial numbers for OpenPGP cards and Yubikeys
rKLEOPATRA00b7174ee7df: Use the display serial number provided by the card
rKLEOPATRAbbe8d775440f: Show nicer card/app labels for the card/app tabs
rKLEOPATRA762726ce6ee6: Show UI for all inserted cards in tabs
rKLEOPATRAff3e79e6cd63: Improve handling of "card not present" situation
rKLEOPATRAd292d1dcdb21: Ensure that we use the correct card app if a card provides multiple apps
rKLEOPATRAf1fff030e342: Get information about all inserted cards and their apps from scdaemon
rKLEOPATRA50237dc66f76: Ensure that card command is run for correct card and app
rKLEOPATRA52c3759c52ed: Work directly with the app names instead of an app type enum
rKLEOPATRA7435acce3c6c: Pass the card/app to work on to the functions triggering a card command
rKLEOPATRA044244a47c1f: Make SetInitialPinCommand work on a card with given serial number
rKLEOPATRA6eac9b662b35: Track first card with Null PIN instead of general "any card has Null PIN"
rKLEOPATRA32c6f48bdf81: Derive all card commands from CardCommand and CardCommand from Command
ikloecker changed the task status from Open to Testing.Oct 13 2020, 10:09 AM

Kleopatra does now support using multiple smartcards with multiple apps concurrently (at least as far as the backend scdaemon supports this). Only tested with master of everything so far.

ikloecker reassigned this task from ikloecker to aheinecke.Oct 13 2020, 10:10 AM
ikloecker added a subscriber: ikloecker.

I am running in a setup where my GnuPG 2.3 is connected to a gpg-agent / scdaemon running at GnuPG 2.2.12.

Sadly, this can happen in the real world because the gpg-agent socket can be forwarded. This may break in that case but for me Kleopatra now runs in an endless start / poll loop:

14:00:32.241 org.kde.pim.kleopatra: Kleo::DeviceInfoWatcher::Worker::start DeviceInfoWatcher::Worker::start: Assuan transaction for SCD DEVINFO --watch started
14:00:32.241 org.kde.pim.kleopatra: Kleo::DeviceInfoWatcher::Worker::poll DeviceInfoWatcher::Worker::poll: context finished with Success (code: 0, source: Unspecified source)
14:00:32.241 org.kde.pim.kleopatra: Kleo::DeviceInfoWatcher::Worker::start DeviceInfoWatcher::Worker::start: Assuan transaction for SCD DEVINFO --watch started
14:00:32.241 org.kde.pim.kleopatra: Kleo::DeviceInfoWatcher::Worker::poll DeviceInfoWatcher::Worker::poll: context finished with Success (code: 0, source: Unspecified source)

The problem here is that:

> getinfo version
D 2.2.12
OK
> scd getinfo version
D 2.2.12
OK
> SCD DEVINFO --watch
ERR 100663571 Unknown IPC command <SCD>

I think the unknown IPC command error is somehow lost in our layers.

Looking at the code I think that either the gpgme_wait in Context::poll should return this error or the Context::startAssuanTransaction should return this error. I'm not sure where it is lost. I don't think we need to support this setup but we should at least figure out where the error is lost.