Skip to content

Commit

Permalink
Merge pull request #179
Browse files Browse the repository at this point in the history
fix: ConnectionFactory incorrectly using SmartCardConnection
  • Loading branch information
DennisDyallo authored Dec 19, 2024
2 parents 9867d2d + 1160d51 commit 4204482
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 10 additions & 9 deletions Yubico.YubiKey/src/Yubico/YubiKey/ConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ public IScpYubiKeyConnection CreateScpConnection(YubiKeyApplication application,
/// </remarks>
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.");
Expand All @@ -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.");
}
Expand Down
6 changes: 2 additions & 4 deletions Yubico.YubiKey/src/Yubico/YubiKey/Oath/OathSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
return;
KeyCollector = null;
base.Dispose(disposing);
}

KeyCollector = null;
base.Dispose(disposing);
}
}
}

0 comments on commit 4204482

Please sign in to comment.