diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/ConnectionFactory.cs b/Yubico.YubiKey/src/Yubico/YubiKey/ConnectionFactory.cs index 9ba7e72b..cca65e5b 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/ConnectionFactory.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/ConnectionFactory.cs @@ -112,14 +112,6 @@ public IScpYubiKeyConnection CreateScpConnection(YubiKeyApplication application, /// public IYubiKeyConnection CreateConnection(YubiKeyApplication application) { - if (_smartCardDevice != null) - { - _log.LogDebug("Connecting via the SmartCard interface."); - - WaitForReclaimTimeout(Transport.SmartCard); - return new SmartCardConnection(_smartCardDevice, application); - } - if (_hidKeyboardDevice != null && application == YubiKeyApplication.Otp) { _log.LogDebug("Connecting via the Keyboard interface."); @@ -128,13 +120,22 @@ public IYubiKeyConnection CreateConnection(YubiKeyApplication application) return new KeyboardConnection(_hidKeyboardDevice); } - if (_hidFidoDevice != null && (application == YubiKeyApplication.Fido2 || application == YubiKeyApplication.FidoU2f)) + bool isFidoApplication = application == YubiKeyApplication.Fido2 || application == YubiKeyApplication.FidoU2f; + if (_hidFidoDevice != null && isFidoApplication) { _log.LogDebug("Connecting via the FIDO interface."); WaitForReclaimTimeout(Transport.HidFido); return new FidoConnection(_hidFidoDevice); } + + if (_smartCardDevice != null) + { + _log.LogDebug("Connecting via the SmartCard interface."); + + WaitForReclaimTimeout(Transport.SmartCard); + return new SmartCardConnection(_smartCardDevice, application); + } throw new InvalidOperationException("No suitable interface present. Unable to establish connection to YubiKey."); } diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Oath/OathSession.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Oath/OathSession.cs index 82407e73..e240eaf7 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Oath/OathSession.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Oath/OathSession.cs @@ -127,11 +127,9 @@ protected override void Dispose(bool disposing) { if (disposing) { - return; + KeyCollector = null; + base.Dispose(disposing); } - - KeyCollector = null; - base.Dispose(disposing); } } }