Improve CCID error handling

Co-Authored-By: Dennis Fokin <dennis.fokin@yubico.com>
This commit is contained in:
Dag Heyman 2020-03-13 12:01:35 +01:00
parent 29426bf602
commit a19c80ec2b
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
3 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import logging
import types
import time
import ykman.logging_setup
import smartcard.pcsc.PCSCExceptions
from base64 import b32encode, b64decode
from binascii import a2b_hex, b2a_hex
from ykman.descriptor import (
@ -117,6 +118,8 @@ def catch_error(f):
raise
except CCIDError:
return failure('ccid_error')
except smartcard.pcsc.PCSCExceptions.EstablishContextException:
return failure('no_pcscd')
except Exception as e:
if str(e) == 'Incorrect padding':
return failure('incorrect_padding')

View File

@ -126,6 +126,8 @@ StackView {
return qsTr('Failed to read from slots')
case 'failed_to_parse_uri':
return qsTr('Failed to read credential from QR code')
case 'no_pcscd':
return qsTr('Is the pcscd/smart card service running?')
default:
return qsTr('Unknown error')
}

View File

@ -239,7 +239,7 @@ Python {
if (!currentDevice || !availableDevices.some(dev => dev.serial === currentDevice.serial)) {
// new device is being loaded, clear any old device
clearCurrentDeviceAndEntries()
navigator.goToLoading()
if (availableDevices.some(dev => dev.selectable)) {
// pick the first selectable device
currentDevice = resp.devices.find(dev => dev.selectable)
@ -309,6 +309,11 @@ Python {
currentDevice.hasPassword = true
currentDeviceValidated = false
navigator.goToEnterPasswordIfNotInSettings()
} else if (resp.error_id === 'open_device_failed') {
clearCurrentDeviceAndEntries()
yubiKey.availableDevices = []
navigator.snackBarError(navigator.getErrorMessage(resp.error_id))
navigator.goToCredentialsIfNotInSettings()
} else {
clearCurrentDeviceAndEntries()
console.log("calculateAll failed:", resp.error_id)